Menu

#123 "unbound wildcard element": "toxml()" fails

PyXB 1.1.4
closed
None
fixed
Binding model
major
PyXB 1.1.3
defect
2012-02-25
2012-02-20
No

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'
2 Attachments

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2012-02-20

    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).

     
  • Dieter Maurer

    Dieter Maurer - 2012-02-20

    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

      ...
      Module "pyxb.binding.basis.py", line 2186, in _toDOM_csc
        dom_support.appendChild(v, element)
       Module "pyxb.utils.domutils.py", line 617, in appendChild
        child = self.cloneIntoImplementation(child)
       Module "pyxb.utils.domutils.py", line 599, in cloneIntoImplementation
        return self._deepClone(node, new_doc)
       Module "pyxb.utils.domutils.py", line 578, in _deepClone
        clone_node.setAttributeNodeNS(self._deepClone(attr, docnode))
       Module "pyxb.utils.domutils.py", line 574, in _deepClone
        if node.ELEMENT_NODE == node.nodeType:
    AttributeError: 'unicode' object has no attribute 'ELEMENT_NODE'
    
     
  • Dieter Maurer

    Dieter Maurer - 2012-02-20

    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)

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-02-25

    patch for absent namespace in cloned nodes (requires all #114 patches)

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-02-25
    • status changed from new to closed
    • resolution set to fixed

    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.

     
MongoDB Logo MongoDB