Actually, one update, otherwise traversal could continue needlessly.

> 
> 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 ) )
            {
                rhsResults.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

Reply via email to