[Expat-discuss] How to stop parsing a block at a appl-level error
karl at waclawek.net
Wed Oct 4 21:20:24 CEST 2006
Andre Luis Monteiro wrote:
> I'm one more Expat newbie just amazed by the conceptual simplicity and roubustness of this lib / API. Great work!
> I'm building a C parser state machine on top of Expat, targeting config XML files. It was quite easy to code, and it's working fine and fast.
> But I'm not satisfied with it's error handling, since the "semantic errors" -- XML structure errors or application-level errors derived from config actions -- must be "postponed" to the next XML document block to parse; I have not found a (fancy) manner to handle them as soon as they are found, stopping further parsing and returning the XML_Parser info (like line number and column etc.).
Have a look at the XML_StopParser and related functions.
> I didn't understand why the XML handler typedefs (like XML_StartElementHandler) do not declare a return value that could signal "user errors", in such a way that applications (XML parsers) could tell Expat to "get away with the shit" in a simple manner. Please explain the reasons why, ok? I'm a novice, just learning XML, SAX, Expat.
Historical reasons of backward compatibility.
If there is ever an Expat 3.0 line of versions, such a return value
would likely be added.
> Moreover, please tell me how to stop the parsing and return as soon as an application-level error could be found (in a XML_StartElementHandler or a XML_EndElementHandler, for ex.).
More information about the Expat-discuss