I am not overjoyed with the solution, it's only for dom4j (at the moment), but I tried to limit the object creation, it's only O(treesize) and it reverts (supposed to anyway) to the old way for non-supported node types.
I am attaching the complete files so people can read it w/o patching. If accepted, I'll send real diffs... src/java/main/org/jaxen/ContextGather.java src/java/main/org/jaxen/expr/DefaultUnionExpr.java For testing : src/java/test/org/jaxen/dom4j/XPathOrderTest.java xml/order.xml -- Geir Magnusson Jr. [EMAIL PROTECTED] System and Software Consulting Be a giant. Take giant steps. Do giant things...
order.xml
Description: Binary data
ContextGather.java
Description: Binary data
DefaultUnionExpr.java
Description: Binary data
XPathOrderTest.java
Description: Binary data