Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion exist-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@
<include>src/test/java/org/exist/xquery/functions/xmldb/XMLDBStoreTest.java</include>
<include>src/test/java/org/exist/xquery/functions/xquery3/SerializeTest.java</include>
<include>src/test/java/org/exist/xquery/value/DateTimeTypesTest.java</include>
<include>src/test/xquery/emptySeq.xq</include>
<include>src/test/xquery/startWithComp.xq</include>
</includes>
</licenseSet>

Expand Down Expand Up @@ -1085,6 +1087,8 @@
<include>src/main/java/org/exist/xslt/EXistURIResolver.java</include>
<include>src/main/java/org/exist/xslt/XsltURIResolverHelper.java</include>
<include>src/test/java/org/exist/xupdate/RemoveAppendTest.java</include>
<include>src/main/java/org/exist/xquery/GeneralComparison.java</include>
<include>src/main/java/org/exist/xquery/Predicate.java</include>
</includes>
</licenseSet>

Expand Down Expand Up @@ -1538,7 +1542,10 @@
<exclude>src/main/java/org/exist/xslt/EXistURIResolver.java</exclude>
<exclude>src/main/java/org/exist/xslt/XsltURIResolverHelper.java</exclude>
<exclude>src/test/java/org/exist/xupdate/RemoveAppendTest.java</exclude>

<exclude>src/main/java/org/exist/xquery/GeneralComparison.java</exclude>
<exclude>src/test/xquery/emptySeq.xq</exclude>
<exclude>src/main/java/org/exist/xquery/Predicate.java</exclude>
<exclude>src/test/xquery/startWithComp.xq</exclude>
<!--
Derivative work licensed under dbXML 1.0 and LGPL 2.1
-->
Expand Down
27 changes: 27 additions & 0 deletions exist-core/src/main/java/org/exist/xquery/GeneralComparison.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* [email protected]
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand Down Expand Up @@ -648,6 +672,9 @@ protected Sequence nodeSetCompare( NodeSet nodes, Sequence contextSequence ) thr
}
}
}
if (result.isEmpty()) {
return BooleanValue.FALSE;
}
}

if( context.getProfiler().traceFunctions() ) {
Expand Down
34 changes: 33 additions & 1 deletion exist-core/src/main/java/org/exist/xquery/Predicate.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* [email protected]
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand Down Expand Up @@ -36,6 +60,7 @@
import org.exist.xquery.value.SequenceIterator;
import org.exist.xquery.value.Type;
import org.exist.xquery.value.ValueSequence;
import org.exist.xquery.value.BooleanValue;

import javax.annotation.Nullable;
import java.util.Set;
Expand Down Expand Up @@ -377,7 +402,14 @@ private Sequence selectByNodeSet(final Sequence contextSequence) throws XPathExc
final NodeSet contextSet = contextSequence.toNodeSet();
final boolean contextIsVirtual = contextSet instanceof VirtualNodeSet;
contextSet.setTrackMatches(false);
final NodeSet nodes = super.eval(contextSet, null).toNodeSet();
final Sequence res = super.eval(contextSet, null);
if(!(res instanceof NodeSet)) {
if(res == BooleanValue.FALSE)
return NodeSet.EMPTY_SET;
return res;
}
final NodeSet nodes = res.toNodeSet();

/*
* if the predicate expression returns results from the cache we can
* also return the cached result.
Expand Down
58 changes: 58 additions & 0 deletions exist-core/src/test/xquery/emptySeq.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
(:
: Elemental
: Copyright (C) 2024, Evolved Binary Ltd
:
: [email protected]
: https://www.evolvedbinary.com | https://www.elemental.xyz
:
: This library is free software; you can redistribute it and/or
: modify it under the terms of the GNU Lesser General Public
: License as published by the Free Software Foundation; version 2.1.
:
: This library is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
: Lesser General Public License for more details.
:
: You should have received a copy of the GNU Lesser General Public
: License along with this library; if not, write to the Free Software
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
:)
xquery version "3.1";

module namespace t="http://exist-db.org/xquery/test";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $t:XML := document {
<F id="1"/>
};

declare
%test:setUp
function t:setup() {
xmldb:create-collection("/db", "test"),
xmldb:store("/db/test", "test.xml", $t:XML)
};

declare
%test:tearDown
function t:tearDown() {
xmldb:remove("/db/test")
};

declare
%test:assertTrue
function t:test-db() {
exists(
doc("/db/test/test.xml")//F[boolean(count(@id >= 2))]
)
};

declare
%test:assertTrue
function t:test-mem() {
exists(
$t:XML//F[boolean(count(@id >= 2))]
)
};
52 changes: 52 additions & 0 deletions exist-core/src/test/xquery/startWithComp.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(:
: Elemental
: Copyright (C) 2024, Evolved Binary Ltd
:
: [email protected]
: https://www.evolvedbinary.com | https://www.elemental.xyz
:
: This library is free software; you can redistribute it and/or
: modify it under the terms of the GNU Lesser General Public
: License as published by the Free Software Foundation; version 2.1.
:
: This library is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
: Lesser General Public License for more details.
:
: You should have received a copy of the GNU Lesser General Public
: License along with this library; if not, write to the Free Software
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
:)
xquery version "3.1";

module namespace t="http://exist-db.org/xquery/test";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $t:XML := document {
<Y1 id="1">
<H1 id="2" a2="2">true</H1>
</Y1>
};

declare
%test:setUp
function t:setup() {
let $testCol := xmldb:create-collection("/db", "test")
return
xmldb:store("/db/test", "test.xml", $t:XML)
};

declare
%test:tearDown
function t:tearDown() {
xmldb:remove("/db/test")
};

declare
%test:assertTrue
function t:test() {
doc("/db/test/test.xml")//*[starts-with(@a2, "1") = false()]
=> exists()
};
Loading