Hi Donald
I can't see anything wrong with the code. Could it be that NodeComparator
compares the names of hte documents as well? (A document has a name). Maybe
we should patch NodeComparator to not use the document name in the
comparison.
You can test if this is the issue by....
Document doc1 = ...;
Document doc2 = ...;
doc1.setName( "foo" );
doc2.setName( "foo" );
if ( comparator.compareTo( doc1, doc2 ) != 0 ) {
... failed...
James
----- Original Message -----
From: "Donald Ball" <[EMAIL PROTECTED]>
To: "dom4j" <[EMAIL PROTECTED]>
Sent: Wednesday, April 24, 2002 5:58 AM
Subject: [dom4j-user] NodeComparator broken?
> the NodeComparator class seems to be broken for me. i'm comparing two
> documents which are identical in value, yet compare returns 1. i
> serialize the two documents to files before the test and verify that
> yes, even md5sum agrees they're the same bytes. if the two documents
> serialize to the exact same xml document, doesn't that necessarily imply
> they compare as equal?
>
> here's a fragment of my code. known_document and unknown_document are
> Documents, of course:
>
> OutputFormat outformat = OutputFormat.createPrettyPrint();
> outformat.setEncoding("UTF-8");
> XMLWriter writer = new XMLWriter(new
> FileOutputStream("known.xml"), outformat);
> writer.write(known_document);
> writer.flush();
> writer = new XMLWriter(new FileOutputStream("unknown.xml"),
> outformat);
> writer.write(unknown_document);
> writer.flush();
> NodeComparator comparator = new NodeComparator();
> assertEquals(0, comparator.compare(known_document,
> unknown_document));
>
> any help would be greatly appreciated. i'd rather not have to serialize
> the documents to byte arrays to compare them reliably.
>
> - donald
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user