Skip to content
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

Make .nsmap available in XSLT extensions. #269

Merged
merged 1 commit into from Apr 5, 2019

Conversation

@adelton
Copy link
Contributor

commented Aug 9, 2018

When adding namespaced elements/attributes in execute of XSLT extension element, new xmlns declaration is generated with prefix ns0. At the same time it does not seem to be possible to figure out what are the existing namespaces and prefixes in the input_node, resulting in

AttributeError: 'lxml.etree._ReadOnlyElementProxy' object has no attribute 'nsmap'

This patch makes it possible to see the namespace map.

@@ -290,6 +290,26 @@ cdef class _ReadOnlyElementProxy(_ReadOnlyProxy):
return funicode(self._c_node.ns.prefix)
return None

property nsmap:

This comment has been minimized.

Copy link
@scoder

scoder Aug 9, 2018

Member

Looks like a copy of _Element.nsmap, so the dict building should go into a shared helper function.

extensions = { ('extns', 'show-nsmap') : MyExt() }

result = tree.xslt(style, extensions=extensions)
self.assertEqual(etree.tostring(result, pretty_print=True), """\

This comment has been minimized.

Copy link
@scoder

scoder Aug 9, 2018

Member

This needs to compare to a bytes literal to work in Py3.

@scoder

This comment has been minimized.

Copy link
Member

commented Aug 9, 2018

Documentation and docstring missing. Changelog entry would also be nice.

@scoder scoder added the feature label Aug 9, 2018

@adelton

This comment has been minimized.

Copy link
Contributor Author

commented Apr 5, 2019

I'm afraid I won't be able to address the comments in the review in foreseeable future. Would you prefer this pull request closed, or left open, for the off chance that someone else in the community has the need and time to polish this?

@scoder scoder merged commit 9b9136b into lxml:master Apr 5, 2019

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.