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