You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there!
I've faced an issue that slaxdom failed to build a DOM for document that have a <!DOCTYPE>.
w3 says it is valid: https://www.w3.org/TR/xml/#NT-doctypedecl
Minimal test-case:
sd=require"slaxdom"z=sd:dom("<!DOCTYPE><a></a>")
The error would be:
/usr/share/lua/5.1/slaxdom.lua:34: Documenthasnon-whitespacetextatroot: '<!DOCTYPE>'Stacktraceback:
At=[C]:-1 (inglobalerror)
At @/usr/share/lua/5.1/slaxdom.lua:34 (infieldtext)
0031: end,
0032: text=function(value,cdata)
0033: -- documents may only have text node children that are whitespace: https://www.w3.org/TR/xml/#NT-Misc0034: ifcurrent.type=='document' andnotvalue:find('^%s+$') thenerror(("Document has non-whitespace text at root: '%s'"):format(value:gsub('[\r\n\t]',{['\r']='\\r', ['\n']='\\n', ['\t']='\\t'}))) end0035: push(current.kids,{type='text',name='#text',cdata=cdataandtrueornil,value=value,parent=richandcurrentornil})
0036: end,
0037: comment=function(value)
At @/usr/share/lua/5.1/slaxml.lua:87 (inupvaluefinishText)
0084: text=gsub(text,'%s+$','')
0085: if#text==0thentext=nilend0086: end0087: iftextthenself._call.text(unescape(text),false) end0088: end0089: end0090:
At @/usr/share/lua/5.1/slaxml.lua:125 (inlocalstartElement)
0122: iffirstthen0123: currentElement[2] =nil-- reset the nsURI, since this table is re-used0124: currentElement[3] =nil-- reset the nsPrefix, since this table is re-used0125: finishText()
0126: pos=last+10127: first,last,match2=find(xml, '^:([%a_][%w_.-]*)', pos )
0128: iffirstthenAt @/usr/share/lua/5.1/slaxml.lua:239 (inmethodparse)
0236: whilepos<#xmldo0237: ifstate=="text" then0238: ifnot (findPI() orfindComment() orfindCDATA() orfindElementClose()) then0239: ifstartElement() then0240: state="attributes"0241: else0242: first, last=find( xml, '^[^<]+', pos )
At @/usr/share/lua/5.1/slaxdom.lua:44 (inmethoddom)
0041: push(current.kids,{type='pi',name=name,value=value,parent=richandcurrentornil})
0042: end0043: }
0044: builder:parse(xml,opts)
0045: returndoc0046: end0047:
Atstdin#22:1 (in ?)
0001: z=sd:dom("<!DOCTYPE><a></a>")
For now, I working that around by converting doctype to comment, and "uncommenting" it again right before serialization, but it would be nice if it will work out-of-the box :)
The text was updated successfully, but these errors were encountered:
Hi there!
I've faced an issue that slaxdom failed to build a DOM for document that have a
<!DOCTYPE>
.w3 says it is valid: https://www.w3.org/TR/xml/#NT-doctypedecl
Minimal test-case:
The error would be:
For now, I working that around by converting doctype to comment, and "uncommenting" it again right before serialization, but it would be nice if it will work out-of-the box :)
The text was updated successfully, but these errors were encountered: