michaelrsweet / mxml

Tiny XML library.
https://www.msweet.org/mxml
Apache License 2.0
428 stars 157 forks source link

Stop SAX parsing from callback #51

Closed michaelrsweet closed 2 months ago

michaelrsweet commented 16 years ago

Version: 3.x-feature Original reporter: Michael Sweet

In a project i'm currently working on we have xml-files of several MB's. As i don't want to read the whole document in memory i will use the new SAX API. From this document i only want to read the attributes of the rootnode.

It would be nice if we could stop the stream parsing if we have found what we were looking for. So we don't need to read through the whole document.

michaelrsweet commented 16 years ago

Original reporter: Michael Sweet

Unfortunately, the current mxml_sax_cb_t function can't return a value, so this isn't something I can easily add support for without breaking compatibility with existing apps.

I'll keep this feature request open, but don't expect an implementation until at least Mini-XML 3.0 (which isn't even planned at this point...)

michaelrsweet commented 16 years ago

Original reporter: Michael Sweet

No problem, i patched the code myself to get it working.

Maybe it's possible to add an extra boolean parameter to be able to quit the parsing. With a default value of false, you won't break existing applications.

michaelrsweet commented 14 years ago

Original reporter:

Hi leon.wennekers,

currently I have the same issue. I want to stop parsing the XML file.

I read that you have added the feature to stop parsing XML files to minixml. May I ask you, if it is possible to get your patch?

Greetings Drake

michaelrsweet commented 13 years ago

Original reporter: Michael Sweet

Moving this to the Mini-XML 3.0 timeframe.

michaelrsweet commented 5 years ago

OK, I'm scoping the changes that will land in Mini-XML 3.0 and I think I will be holding off on breaking API changes for now, sorry...

GPaso commented 3 years ago

I am working on a C project in which this feature could be very useful, but you say that the patch will break retro-compatibility?

michaelrsweet commented 3 years ago

@GPaso Yes because changing the SAX callback function to return a value (right now it is a void function) will break existing users of the API.

GPaso commented 3 years ago

Is not feasible to implement a function, which can be called from the callback, that stops the SAX parsing? This should not brake compatibility

michaelrsweet commented 3 years ago

@GPaso It is not feasible since there is no context information in the callback that could be used for this, and Mini-XML is a multi-threaded library. I'm not going to hack together a solution, but will include this in the next major release when I can safely break backwards-compatibility.

michaelrsweet commented 2 months ago

[master 3df751f] SAX callback now returns a boolean (Issue #51)