Title: canonicalization fails
Hi,
 
I found the problem. I had to use element.setAttributeNS( namespaceUri, namespacePrefix + ":" + attributeName, attributeValue ). Also, for the namespace definition attributes, the syntax I use is element.setAttributeNS( "http://www.w3.org/2000/xmlns/", "xmlns:test_ns", "some_url" ). It works this way.
Regardless of the above, shouldn't the class NonNSAttrComparator have used attribute.getNodeName() instead of attribute.getLocalName() for the non-namespaced attributes?
 
Thanks,
 Marius
-----Original Message-----
From: Marius Constantin
Sent: Wednesday, December 10, 2003 11:43 AM
To: [EMAIL PROTECTED]
Subject: canonicalization fails

Hi all,

Here is the scenario:
 - I parse an XML from an stream.
 - I use the Document instance to create a new Element node (elNode). I add two attributes to it. One of these attributes is a namespace definition. I add it using elNode.setAttribute( "xmlns:ns1", "http://localhost/temp" )

 - After this I sign the message. It fails in the Canonicalizer, when it tries to sort the attributes (NonNSAttrCompare.compare; the call to the attr.getLocalName returns null for both attributes.) What I observed is that all the other attributes (of the nodes parsed from the stream,) are sorted using the NSAttrCompare class. Going further, I have observed that the Element I create is an instance of ElementNSImpl and its attributes are AttrImpl whereas all the other Element nodes are DeferredElementNSImpl and their attributes are DeferredAttrNSImpl... I think the problem lies somewhere in this area but I couldn't find a way to create the "Deferred" types...

Am I on the right path? Any ideas, suggestions on how to go ahead with this?

Thanks,
 Marius

Reply via email to