-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support XML Namespaces in Writer #40
Comments
I think allowing the namespace prefix to be auto-generated is a good idea, although I would also like to allow optionally assigning a custom prefix to the namespace, to support a more human-readable output format for cases where certain namespaces have conventional prefixes. What I'm starting on to make more progress towards #10 is planned to look something like this:
(just as Another goal of #10 is to have configurable safety checks which should ideally be able to catch any well-formedness errors when using any of these functions, but that's a longer term goal and I don't think I'll include that in the initial implementation of this. |
that sounds great :D I've hacked something together here which allows introducing namespaces and applying namespaces to element names (not attributes yet) with elementStartNs. It generates prefixes for you but doesn't yet allow user-supplied ones. I'll tweak it a bit and see if I can bring it into line with your suggested API. |
Thanks! I actually have an initial version locally, where I'm also planning to fill out the test suite and doc comments, but it'll likely be a few days until it's completely ready, though. |
Closes #40 In addition to the new namespace-aware functions, this commit brings several other enhancements: - The element name has been removed as an argument of `elementEnd`. The writer now keeps track of the current open element automatically. - Doctests have been added for all public writer functions. - Doc comments have been added for all public writer functions.
I opened #41 with an initial implementation of the API outlined above. All the tests I added are passing, but I'm going to take another look at it later before merging to make sure I didn't miss anything. |
Related to #10
Currently the Writer API does not explicitly support namespaces.
It's possible to mostly work around it by adding the appropriate XML attributes:
however, this means it's now down to the library user to track which namespace prefix is used for which namespace and specify element names with the appropriate prefix in child nodes. The prefix has no meaning except to identify the namespace.
Ideally the writer API would handle this for us; when calling
Writer.elementStart
there should be an option to specify the namespace of the current element; as well as optionally setting the current default and non-default namespaces. The writer could handle assigning prefixes to namespaces.The text was updated successfully, but these errors were encountered: