error reporting by the parser
Simple, lightweight XML parser in C, statically or dynamically linked.
Brought to you by:
matthieu-labas
xml 1.
<FATHER>
</FATHER>
<x>
xml 2.
<x>
<FATHER>
</FATHER>
parser do not report any error
xml 3.
<FATHER>
<x y="t>tekst</x>
</FATHER>
<FATHER2>
</FATHER2>
on the line with the missing quotation mark (line nr 2) parser do not reports error ,
but on the end of file (line nr 5):
test.xml:5: An error was found (UNEXPECTED_END_OF_FILE(-4)), loading aborted...
Error while loading
Diff:
This is (somehow) expected behaviour:
sxmlcwas designed to handle multiple root nodes, so bothxml1andxml2are showing two root nodes. However, one of them is not finished so a warning could be raised. I'll prepare a feature request on that.The error reported in
xml3was expected as I remember I read in some specs that>was legal in XML attribute values. However, I can't find that anymore, but could find several links showing it was illegal. As I wantsxmlcto be as permissive as possible (i.e. be able to parse malformed XML data (to some extent)), I will think about the easiest way to solve that. The example you show clearly is a missing quote, so I think I'll just report an error when<>are in the attributes.Fixed in v4.2.10.
Though parser will not report an error on unfinished root tags. At the moment it should be considered a warning: SAX will stop parsing and the caller should check that open nodes were not finished; DOM will just leave nodes as they are (i.e. no new nodes are added to the "unfinished" nodes, though there are no way to know they were not finished).