From: Wolfgang M. M. <wol...@us...> - 2004-07-15 19:41:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9151/src/org/exist/xquery Modified Files: BindingExpression.java Log Message: "where" clause in FLWOR expression selected wrong nodes. Index: BindingExpression.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/BindingExpression.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BindingExpression.java 30 Jun 2004 15:56:59 -0000 1.4 --- BindingExpression.java 15 Jul 2004 19:41:04 -0000 1.5 *************** *** 32,35 **** --- 32,36 ---- import org.exist.dom.NodeProxy; import org.exist.dom.NodeSet; + import org.exist.dom.VirtualNodeSet; import org.exist.xquery.value.BooleanValue; import org.exist.xquery.value.Item; *************** *** 117,121 **** // if the where expression returns a node set, check the context // node of each node in the set ! NodeSet temp = whereExpr.eval(contextSequence).toNodeSet(); NodeProxy current; ContextItem contextNode; --- 118,124 ---- // if the where expression returns a node set, check the context // node of each node in the set ! NodeSet contextSet = contextSequence.toNodeSet(); ! boolean contextIsVirtual = contextSet instanceof VirtualNodeSet; ! NodeSet nodes = whereExpr.eval(contextSequence).toNodeSet(); NodeProxy current; ContextItem contextNode; *************** *** 124,142 **** int count = 0, sizeHint = -1; NodeSet result = new ExtArrayNodeSet(); ! for (Iterator i = temp.iterator(); i.hasNext(); count++) { current = (NodeProxy) i.next(); ! if (lastDoc == null || current.doc != lastDoc) { lastDoc = current.doc; ! sizeHint = temp.getSizeHint(lastDoc); } contextNode = current.getContext(); if (contextNode == null) { ! throw new XPathException("Internal evaluation error: context node is missing!"); } while (contextNode != null) { next = contextNode.getNode(); ! next.addMatches(current); ! if (!result.contains(next)) result.add(next, sizeHint); contextNode = contextNode.getNextItem(); } --- 127,147 ---- int count = 0, sizeHint = -1; NodeSet result = new ExtArrayNodeSet(); ! for (Iterator i = nodes.iterator(); i.hasNext(); count++) { current = (NodeProxy) i.next(); ! if(lastDoc == null || current.doc != lastDoc) { lastDoc = current.doc; ! sizeHint = nodes.getSizeHint(lastDoc); } contextNode = current.getContext(); if (contextNode == null) { ! throw new XPathException("Internal evaluation error: context node is missing for node " + ! current.gid + "!"); } while (contextNode != null) { next = contextNode.getNode(); ! if(contextIsVirtual || contextSet.contains(next)) { ! next.addMatches(current); result.add(next, sizeHint); + } contextNode = contextNode.getNextItem(); } |