Details
Description
migrated issue from sourceforge
Hi all,
Please find attached a patch that allows the org.jaxen.dom.DocumentNavigator class to handle entity references.
Entity references are tricky to deal with using the W3C DOM model, since they involve a degress of travesing up and down when looking for nodes that XPath sees as being at the same depth in the tree.
As a consequence the code is not as clean as the original DOM implementation. In fact, you'll see a fair degree of redundancy in getChildAxisIterator and getFollowingSiblingAxisIterator. In fact getPrecedingAxisIterator follows a very similar pattern as well.
I've done some basic testing of the code against DOM 1 (though I see no reason why DOM 2 wouldn't work just as well). I guess you'll be after some test cases at some point as well.
The code is patched against the 1.0-beta-7 release, though a quick look at CVS doesn't show any more recent changes to the DocumentNavigator.
I'm subscribed to the mailing list, so if you have any questions, I'll be listening there.
Cheers,
Nicholas Cull
run2000@users.sourceforge.net
Mea culpa!
I ran my original patch through the JUnit tests, and spotted
a problem with the parent axis iterator. The newer patch
fixes this by testing for null before trying to test the
parent node's type.
The new patch now passes all the existing test cases on the
DOM model. I'll see if I can construct some simple tests
that show that entity references actually work correctly for
DOM shortly. I'll have difficulty making these generic
though, since some of the other XML models will surely have
the same problems that the DOM navigator had with entity
handling.
Cheers,
Nicholas Cull
run2000@users.sourceforge.net
"Better factored patch that still works (v4)" (patch was to 1.0.b7)