-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Let ElementTreeProducer use the available namespaces #267
Conversation
Tests are missing, should probably go into |
ElementTreeProducer would ignore the namespace prefixes that were available in the element tree, and always generate new prefixes like ns00, ns01 etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I think preferring the current prefix is a good idea. I left comments on the rest.
I'm not sure what happened with the tests here. I did, after much trouble replicate this locally, but I have no clue what is going on. |
I think that's the latest libxml2 release that strikes here, 2.9.9-rc1. I reported the problem on their side and configured the travis build (in the master branch) to use the previous release, which seems to work correctly. Rebasing on master should fix this. Sorry for the inconvenience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Looks much better now!
continue | ||
break | ||
prefix = min(pfx for (pfx, uri) in nsmap.items() | ||
if pfx is not None and uri == ns_uri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing to think about: this will fail now if there is only the default prefix or if the URI does not have a prefix. (min()
requires at least one value.) The second case probably shouldn't happen (and could be considered an actual error case), but the first seems ok and shouldn't fail.
Thanks for your sustained work on this. |
No worries, it's been fun. Thanks for the help! |
sax.ElementTreeProducer would ignore the namespace prefixes that were available in the element tree, and always generate new prefixes like ns00, ns01 etc.
This PR uses the prefixes in the XML by looking at the elements nsmap.