Another property that might help is to explicitly combine adjacent text SAX events into a single Text node.
SAXReader reader = new SAXReader(); reader.setMergeAdjacentText(true); reader.setStripWhitespaceText(true); Note that the whitespace stripping only strips whitespace from end element/start element blocks. So this XML <foo> <bar/> </foo> would have no whitespace. However this <foo> this is some text </for> would have lots. We could probably do with a 'normalizeWhitespace' method that would turn any continuous whitespace into a single ' ' character or something. Maybe you could write one and submit it for inclusing in the distribution? :-) James ------- http://radio.weblogs.com/0112098/ ----- Original Message ----- From: "Calen Martin D. Legaspi" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 19, 2002 10:03 AM Subject: [dom4j-user] whitespace, NodeComparator, and SAXReader question > I'm trying to compare to xml files, such that the comparison is > insensitive to whitespace. I used the method "setStripWhitespaceText()" > in the hope of making the SAXReader insensitive to whitespace. However, > when I use NodeComparator.compareContent(), I do not get the desired > zero even if the only difference between the two xml docs is whitespace > within an element. Below is my code: > > > SAXReader r = new SAXReader(); > r.setStripWhitespaceText(true); > Document docTest = r.read("TestFiles/test.mapping.xsl"); > Document docTestTest = r.read("TestFiles/test.test.mapping.xsl"); > > NodeComparator c = new NodeComparator(); > System.out.println("Result of comparison: " + c.compareContent(docTest, > docTestTest)); > > > Thanks for your reply! > > BTW, dom4j is definitely the best XML API I've ever used, and I actively > endorse it to all my friends. Thanks to the project owners and all the > contributors for creating an API that is making me look good with my > bosses. > > ;) > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user > __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user