On 12/13/01 5:34 AM, "Christian Nentwich" <[EMAIL PROTECTED]> wrote:
> On Thu, 2001-12-13 at 04:49, Geir Magnusson Jr. wrote: >> 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. > > O(treesize) sounds pretty harsh actually. I'm querying 30 megabyte > documents.. Do you think something clever can be done to speed it up? Ok - learning a bit as I go along. I'll fess-up that it's hard - I am unfamiliar with most of the Xpath basics (but learning as rapidly as I can...) So there may be conceptual holes... Forget that stupid gather thingy I did last night. Turns out I can use your generic solution, the Navigator :) So here is the next try. It still sucks in that it's at worst O(size), but it's getting better, and doesn't do a pre traversal.. >From DefaultUnionExpr public Object evaluate(Context context) throws JaxenException { List results = new ArrayList(); List lhsResults = convertToList( getLHS().evaluate( context ) ); List rhsResults = convertToList( getRHS().evaluate( context ) ); Navigator nav = context.getNavigator(); List nodes = context.getNodeSet(); int size = nodes.size(); /* * do this only while there are nodes to sort */ for( int i = 0; i < size && ( lhsResults.size() > 0 || rhsResults.size() > 0 ); i ++) { /* * for each node in this context, get ordered decendant iterator */ Iterator it = nav.getDescendantAxisIterator( nodes.get(i) ); /* * again, only if something to do... */ while( it.hasNext() && ( lhsResults.size() > 0 || rhsResults.size() > 0 )) { Object n = it.next(); if ( lhsResults.remove( n ) ) results.add( n ); else if (rhsResults.remove( n ) ) results.add( n ); } } return results; } -- Geir Magnusson Jr. [EMAIL PROTECTED] System and Software Consulting "Whoever would overthrow the liberty of a nation must begin by subduing the freeness of speech." - Benjamin Franklin _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest