-
Notifications
You must be signed in to change notification settings - Fork 63
Add Stream.Render.document function #205
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
Conversation
|
If we add From a practical perspective, in its current semantics:
From a theoretical perspective, What do you think ? |
|
Good point! You're right, if we add However, having reflected on your thoughts for a while, maybe we should move away from the pragmatic solution in #129 (manually yielding an
If I don't miss anything, this should make the If you're fine with this suggestion I can update the PR and you can have another look. OK? |
|
I imagine users might want any one of the following semantics:
Today, Thus, I have the feeling What do you think ? 🙂 |
|
Well, personally, I'm fine with having only options 2 and 3 because they allow me to be explicit about the presence of an XML declaration in my rendered output. But that may be just me. ;-) As to option 1, is this really possible today (or at all)? Maybe I don't understand the use case correctly, but if it is about parsing XML, processing it, and rendering it again, and about preserving an XML declaration that is (or is not) present in the input so that it appears again (or still doesn't) in the output - I'm not sure how this would work. For example, if I run something like vs. ... I get the exact same output, in both cases starting with But if the information about the presence or absence of an XML declaration in the input is already lost after parsing I don't see how it can be preserved, making option 1 impossible anyway. (Or am I missing something?) However, if you ask me, this is no problem because I don't think the XML declaration has any semantic value that must be preserved. I would rather consider it a syntactic detail, in a similar area as pretty printing; which, come to think of it, somehow justifies it being configured in the So, I have no strong feelings about this but I lean a little more towards keeping the |
|
Oh, maybe there's yet another option. :-) Today, when working with the Text.XML.Stream.Render module, one usually builds a stream out of high-level So maybe we could add another high-level function Another, maybe too drastic thought regarding |
I hadn't realized that the parser behaved like that, fair point.
Not clear to me what the intent was exactly, but you can check the description of the commit that introduced that feature. Off the top of my head, I could imagine a scenario where one needs to render an XML document and then nest it inside another XML document, in which case the intermediate XML declaration becomes undesired.
That sounds like an elegant and practical solution. And again, I have the feeling it makes |
Ha, I knew I was too unimaginative! ;-) Yes, that sounds like something that happens in real life. This could be approached by not wrapping the stream in the proposed
Yes, I think that makes
A less contrived reason for keeping So let me suggest to proceed as follows then:
If this sounds good, I would like your thoughts on the
The first variant allows to create an empty document (but who needs that?), while the second ensures that a document contains exactly one root element (which in my head resonates with the "make invalid states unrepresentable" mantra). I very much prefer the second variant, but maybe that's not flexible enough? |
Your plan sounds good to me 🙂 .
Although well-formed XML documents must indeed have a unique root tag/element, users might want to insert extra events between
Thus, I suggest going with the first signature
Even though it's down the road, I'd like to clarify one point: the moment we remove That way, in a pipeline like
|
Fair enough! I have implemented I haven't yet touched |
|
Thanks for merging, and thanks for your quick answers, your thoughts, and your openness for discussion! Contributing to this project was a very pleasant experience. 👍 Anyway, I think I still owe you an answer regarding the
After some digging in the parser code I don't think this is how it works today. For the parser, The parser (unless in the case of severe errors, I suppose) pretty much always returns an
So essentially, removing Therefore, I now think having the Footnotes |
|
Included in release 1.10.1.0.
That's my point: maybe that behavior of the parser should change, so that
It is justified given the current behavior of the parser, hence my line of reasoning: if we change that behavior, maybe we can afford to remove Anyway, that's drifting out of the scope of the original pull-request, and it can be dealt with later, so don't mind me.
Thank you for contributing, and for taking the time to discuss 🙂 . |
Hi,
The new
xmlDeclarationfunction introduced by this PR makes the solution proposed in #129 part of the API.I wondered how to add an XML declaration to the rendered XML produced by the streaming API, found nothing in the docs and finally stumbled upon this issue where it is explained. I figured this should be properly documented in the Haddocks or even provided as an - albeit very simple - function.
Should you be opposed to adding new functions to the API we should at least add a note to the docs so the issue mentioned above is not the only place where this info can be found.
Cheers,
Martin