JuliaIO / EzXML.jl

XML/HTML handling tools for primates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid xmlns results in unhandled XML_GLOBAL_ERROR_STACK

lupemba opened this issue · comments

I have tried to parse an xml with an invalid xmlns. This does not throw an error but adds an unhandled element to the XML_GLOBAL_ERROR_STACK. The result of this is that all following calls to parsexml() fails.

Example

import EzXML

invalid_xmlns = 
"""
<?xml version="1.0"?>
<story xmlns="This.is.invalid">
  <storyinfo>
    <author>John Fleck</author>
    <datewritten>June 2, 2002</datewritten>
    <keyword>example keyword</keyword>
  </storyinfo>
  <body>
    <headline>This is the headline</headline>
    <para>This is the body text.</para>
  </body>
</story>
"""


valid_xml = 
"""
<?xml version="1.0"?>
<story xmlns="This.is.invalid">
  <storyinfo>
    <author>John Fleck</author>
    <datewritten>June 2, 2002</datewritten>
    <keyword>example keyword</keyword>
  </storyinfo>
  <body>
    <headline>This is the headline</headline>
    <para>This is the body text.</para>
  </body>
</story>
"""


doc1 = EzXML.parsexml(invalid_xmlns)
doc2 = EzXML.parsexml(valid_xml)

Output

This error is thrown when calling EzXML.parsexml(valid_xml)

ERROR: AssertionError: isempty(XML_GLOBAL_ERROR_STACK)
Stacktrace:
 [1] macro expansion
   @ C:\Users\Kok\.julia\packages\EzXML\ZNwhK\src\error.jl:49 [inlined]
 [2] parsexml(xmlstring::String)
   @ EzXML C:\Users\Kok\.julia\packages\EzXML\ZNwhK\src\document.jl:80
 [3] top-level scope
   @ c:\Users\Kok\Documents\Git repos\SCA_data_example\text_xml_error.jl:40

This was solved with PR #143