Skip to content

Commit e100903

Browse files
committed
[Fix] Predicate nodeset to boolean
1 parent 76d220f commit e100903

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

exist-core/src/main/java/org/exist/xquery/Predicate.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.exist.xquery.value.SequenceIterator;
3737
import org.exist.xquery.value.Type;
3838
import org.exist.xquery.value.ValueSequence;
39+
import org.exist.xquery.value.BooleanValue;
3940

4041
import javax.annotation.Nullable;
4142
import java.util.Set;
@@ -377,10 +378,13 @@ private Sequence selectByNodeSet(final Sequence contextSequence) throws XPathExc
377378
final NodeSet contextSet = contextSequence.toNodeSet();
378379
final boolean contextIsVirtual = contextSet instanceof VirtualNodeSet;
379380
contextSet.setTrackMatches(false);
380-
final Sequence x = super.eval(contextSet, null);
381-
if(!(x instanceof NodeSet))
382-
return x;
383-
final NodeSet nodes = result.toNodeSet();
381+
final Sequence res = super.eval(contextSet, null);
382+
if(!(res instanceof NodeSet)) {
383+
if(res == BooleanValue.FALSE)
384+
return NodeSet.EMPTY_SET;
385+
return res;
386+
}
387+
final NodeSet nodes = res.toNodeSet();
384388

385389
/*
386390
* if the predicate expression returns results from the cache we can

0 commit comments

Comments
 (0)