String cmp = right.eval( docs, context, null ).getStringValue(); cmp = cmp.replace( '*', '%' );
    protected Value nodeSetCompare( Expression left, Expression right, DocumentSet docs,                                    NodeSet context, NodeProxy node ) {        NodeSet result = new ArraySet( 100 );        if ( right.returnsType() == Constants.TYPE_STRING ) {            String cmp = right.eval( docs, context, null ).getStringValue();            cmp = cmp.replace( '*', '%' );            // evaluate left expression            NodeSet nodes;            nodes = (NodeSet) left.eval( docs, context, null ).getNodeList();            // get a list of all nodes equal to ...            DBBroker broker = null;            try {                broker = pool.get();                result = broker.getNodesEqualTo( nodes, docs, relation, cmp );            } catch ( EXistException e ) {                e.printStackTrace();            } finally {                pool.release( broker );            }        }        else if ( right.returnsType() == Constants.TYPE_NUM ) {            double rvalue;            double lvalue;            NodeProxy ln;            NodeSet temp;            NodeSet lset = (NodeSet) left.eval( docs, context, null ).getNodeList();            for ( Iterator i = lset.iterator(); i.hasNext();  ) {                ln = (NodeProxy) i.next();                try {                    lvalue = Double.parseDouble( ln.getNodeValue() );                } catch ( NumberFormatException nfe ) {                    continue;                }                temp = new ArraySet( 1 );                temp.add( ln );                rvalue = right.eval( docs, temp, ln ).getNumericValue();                if ( cmpNumbers( lvalue, rvalue ) )                    result.add( ln );            }        }        else if ( right.returnsType() == Constants.TYPE_BOOL ) {            NodeProxy n;            NodeProxy parent;            boolean rvalue;            boolean lvalue;            long pid;            ArraySet leftNodeSet;            ArraySet temp;            // get left arguments node set            leftNodeSet = (ArraySet) left.eval( docs, context, null ).getNodeList();            temp = new ArraySet( 10 );            // get that part of context for which left argument's node set would            // be > 0            for ( Iterator i = leftNodeSet.iterator(); i.hasNext();  ) {                n = (NodeProxy) i.next();                parent = context.parentWithChild( n, false, true );                if ( parent != null )                    temp.add( parent );            }            // now compare every node of context with the temporary set            for ( Iterator i = context.iterator(); i.hasNext();  ) {                n = (NodeProxy) i.next();                lvalue = temp.contains( n );                rvalue = right.eval( docs, context, n ).getBooleanValue();                if ( cmpBooleans( lvalue, rvalue ) )                    result.add( n );            }        }        return new ValueNodeSet( result );    }