Phrogz / SLAXML

SAX-like streaming XML parser for Lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with undeclared use of xml: namespace

ddurkee opened this issue · comments

I was trying out slaxml and used it with this SVG code from Adobe Illustrator:

<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In  -->
<svg version="1.1"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
     x="0px" y="0px" width="110.6px" height="82px" viewBox="0 0 110.6 82" enable-background="new 0 0 110.6 82" xml:space="preserve"
    >
<defs>
</defs>
<path fill="#B3B0A1" stroke="#000000" stroke-miterlimit="10" d="M3.8,18.4c0,0-9-14.1,12.8-17.3s28.2,6.4,17.9,20.5
    s-37.8,19.2-0.6,25s105.8-58.3,62.2-11.5S29.4,84.5,12.1,80C-5.2,75.5,2,37,2,37"/>
<path fill="#9B9A91" stroke="#000000" stroke-miterlimit="10" d="M27.5,53c0,0-16-14.8,0-24.4s16-1.9,19.2,5.1
    c3.2,7.1,6.4,12.8,0,16c-6.4,3.2-11.3,6.4-11.3,6.4"/>
</svg>

This gave an error in nsForPrefix because the xmlnamespace was not declared. According to Namespaces in XML, "The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared…." See http://www.w3.org/TR/xml-names/. To work around this I changed the line initializing nsStack to:

local nsStack = {{xml="http://www.w3.org/XML/1998/namespace"}}

I also had to change the check at the end from

if #nsStack > 0 then error(...

to

if #nsStack > 1 then error(...

because of this. It seems like another possible solution would be to put in a hard-coded check in nsForPrefix for xml. Maybe that would be better.

Thank you for the report; yes, hardcoding this in nsForPrefix is more correct. I'll make that change now.