-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a streaming API #113
Comments
Frankly, I'm not sure what you mean under streaming here. According to the XML standard, the document is either well-formed or not; well-formedness errors are hard errors, that is, they unconditionally stop the parsing process. If a document does not have a valid element structure (e.g. there is no closing tag for some opening tag), then the document is not well-formed. Additionally, each Could you please explain in detail how exactly what you propose should work and why existing API cannot do the same thing? |
I’m currently trying to write an XMPP client library, and this protocol starts with a prolog, then a The XML “document” that makes this session is well-formed (any error will lead to the stream being closed), and has a few restrictions like no PI, no comment, no doctype/entity declaration, etc. I am currently (ab?)using the My first prototype was creating an I since moved to |
Hmm, I see now, thanks for the explanation. That And I do see the problem with byte sources not implementing
What do you think? |
Hi, sorry for the late reply. Making the parser emit I was indeed wrong, |
@linkmauve note that since the parser is pull-based, events are not triggered in response to the new data in the stream; rather, upon the user request the parser attempts to read more data from the input stream, and thus its behavior depends on the behavior of the source (it may block or return an error). That said, I don't know how I'm also not sure what do you mean under closing the document. The document will be "closed" automatically when the last closing tag arrives. This does not require special actions from the user. |
With #146 being merged, this issue is now fixed, thanks! |
When a document is received in chunks (on XMPP for example), it makes sense to initialize the parser on the first chunk, and then feed it data as it comes.
xml::ParserConfig
would get a newstreaming
boolean that would make it never emitxml::XmlEvent::EndDocument
before the root tag is closed, afeed
method toxml::EventReader
, taking a string and emitting newerxml::XmlEvent
s as they are parsed, and finally add a method to abort the stream.The text was updated successfully, but these errors were encountered: