Very bad form, replying to my own post - but I've tracked it down.

I was calling
el.addNamespace ("deltaxml", "foo");
for the "x" element in the first doc. The second doc's "x" element already 
has a NS decl, inherited from "top".
A nodeIterator() on the first "x" (in a.xml, after addNamespace()) finds 1 
content item - a Namespace. For the second doc, b.xml, a nodeIterator on 
its "x" element gives 0 content items.

So... although asML() gives identical results:
<top xmlns:deltaxml="foo"><x/></top>

the two docs are different because one has a Namespace "node" and the other 
doesn't.

Is this as expected? Workarounds, anyone?
Thanks,
Thomas.



At 21:14 26/11/2001 +0000, Thomas Nichols wrote:
>Good Day,
>
>I'm using the NodeComparator in a regression-test setup - comparing 
>expected with actual results. I get differences if doc B has a namespace 
>declaration that isn't present in A (or vice versa) - even if it's unused. 
>This is important because a "deltaxml" namespace may (but need not be) 
>declared in these docs -- so for these files, a 'deltaxml="foo"' present 
>in one but not the other is an ignorable difference.
>
>For example:
>$cat a.xml
><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
><top><x/></top>
>
>$cat b.xml
><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
><top xmlns:deltaxml="foo"><x/></top>
>
>Calling  topElement.addNamespace ("deltaxml", "foo");  doesn't fix the 
>problem - the NodeComparator still says they're different.
>
>I guessed that this is because the "x" child element in b.xml gets a 
>namespace decl for "foo" when it's initially parsed, and that adding the 
>decl to the "top" element in a.xml does _not_ add it to the child "x" 
>element. However, even recursive addNamespace() calls on all children do 
>not give a tree that matches - even though asXML() gives an apparently 
>identical tree.
>
>Is there any way to change the declared namespaces for an Element and all 
>its children? What about Attributes? I don't understand from 
>NodeComparator.java why this approach isn't working.
>
>======
>
>Notes: Attribute has a getNamespace(), but no addNamespace() -- 
>asymmetrical with Element. Attribute has a setNamespace(Namespace) which 
>is missing from Element.
>I am probably confusing the _declared_ namespaces for a node -- as 
>returned by Attribute.getDeclaredNamespaces(), can't see this for Element 
>-- with the namespace of a particular node -- e.g. <xhtml:head>...</xhtml:head>
>
>Adding 'xmlns:deltaxml="foo"' (unsurprisingly) makes NodeComparator happy.
>
>[ Aside: What causes asXML to output "<x></x>" instead of "<x/>" ? ]
>
>
>Any advice or direction warmly received,
>
>Thanks,
>Thomas.
>
>PS: Isn't dom4j just wonderful?
>
>
>_______________________________________________
>dom4j-user mailing list
>[EMAIL PROTECTED]
>https://lists.sourceforge.net/lists/listinfo/dom4j-user


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to