"unbound wildcard element": "toxml()" fails
Brought to you by:
pabigot
If "CreateFromDocument" creates an "unbound wildcard element", a call of "toxml" of the containing binding object fails as seen by the following example:
>>> doc="""<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI="#_53cdd0e9-bd51-4a49-8519-f711860c5499"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><InclusiveNamespaces PrefixList="#default samlp saml ds xs xsi" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" /></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>4OXjC8LT68JYyCVbtKJims+qe4U=</DigestValue></Reference></SignedInfo><SignatureValue>vG+UCB9C3T8k91yDP2zCvKNHJbp+P1aik9xckByr43y5V5BZktzOF9h4FC8C3mYklg/jTtzWiN4TvAd+wrznpOYDBv3/AseHM+LWG2Q/0t1o8owiliR1z8BqydQUXPuwTSTrPAzEmYFKnq+OQvtq8GiebfYHD2nTKc4M0B8//TuQ295WLwX06RXiuNxGN9C1YvMOL/hHKybPeiVbT7I0wnUMDjf4H/K+4hnCZY2wT+nOBf0fRVkFud/0/lIxCu8T3SMQeSzMRXcdK0FiElFNzh24DJerVwIIZTFXl5Qg42S2Is6kFs1KR0CYDXR/ZVNF5CdVY/xe62t8GUYbTHAoBw==</SignatureValue></Signature>"""
>>>
>>> from pyxb.bundles.wssplat.ds import CreateFromDocument
>>>
>>> b=CreateFromDocument(doc)
NOTE: Created unbound wildcard element from value in InclusiveNamespaces
>>> b.toxml()
Traceback (most recent call last):
...
Module "pyxb.binding.basis.py", line 2186, in _toDOM_csc
element.appendChild(v)
Module "xml.dom.minidom.py", line 125, in appendChild
node.parentNode.removeChild(node)
AttributeError: 'Document' object has no attribute 'removeChild'
This is probably the same a #114, but I'll check it when I have a chance to look at PyXB again (hopefully later this week).
Thank you for the (extremely!) quick response.
It is the same problem but the patches attached to #144 are not yet complete for my example: I get
For me, this patch (in addition to the ones from #114) solved the problem. However, I am not sure that "saxdom" really uses (ns_uri, lname) as attribute keys (as I have assumed)
patch for absent namespace in cloned nodes (requires all #114 patches)
It looks like you didn't apply patch
0004-extend-trac-114-test-to-cover-attributes.patch, since the context in
what you posted was changed in that patch.
With that, though, it turns out there was another problem because the
wildcard clone assumed that both elements and attributes would have an
associated namespace. In fact, they might not: the default namespace in the
InclusiveNamespace element was not applied to the PrefixList attribute.
The attached patch supports deep-cloning nodes that have no namespace.