Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ public NodeSet selectFollowing(final NodeSet pl, final int position, final int c
if(!reference.getNodeId().isDescendantOf(nodes[j].getNodeId())) {
if(position < 0 || ++n == position) {
if (contextId != Expression.IGNORE_CONTEXT
&& contextId != Expression.NO_CONTEXT_ID
&& nodes[j].getContext() != null
&& reference.getContext() != null
&& nodes[j].getContext().getContextId() == reference.getContext().getContextId()) {
Expand Down Expand Up @@ -846,6 +847,7 @@ public NodeSet selectPreceding(final NodeSet pl, final int position,
if(!reference.getNodeId().isDescendantOf(nodes[j].getNodeId())) {
if(position < 0 || ++n == position) {
if (contextId != Expression.IGNORE_CONTEXT
&& contextId != Expression.NO_CONTEXT_ID
&& nodes[j].getContext() != null
&& reference.getContext() != null
&& nodes[j].getContext().getContextId() == reference.getContext().getContextId()) {
Expand Down
38 changes: 38 additions & 0 deletions exist-core/src/test/xquery/axes-persistent-nodes.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ function axpn:preceding-with-predicate-db-map() {
! (./@id || ":" || (./preceding::pb[1]/@id, "PRECEDING_PB_NOT_FOUND")[1])
};

declare
%test:assertEquals("w1:pb1", "w2:pb1", "w3:pb1", "w4:pb2", "w5:pb2")
function axpn:preceding-with-context-predicate-db-flwor() {
for $w in doc("/db/test/test.xml")//w[exists(.)]
let $preceding-page := $w/preceding::pb[1]
return
if ($preceding-page) then
$w/@id || ":" || $preceding-page/@id
else
$w/@id || ":PRECEDING_PB_NOT_FOUND"
};

declare
%test:assertEquals("w1:pb1", "w2:pb1", "w3:pb1", "w4:pb2", "w5:pb2")
function axpn:preceding-with-context-predicate-db-map() {
doc("/db/test/test.xml")//w[exists(.)]
! (./@id || ":" || (./preceding::pb[1]/@id, "PRECEDING_PB_NOT_FOUND")[1])
};

declare
%test:assertEquals("w1:pb1", "w2:pb1", "w3:pb1", "w4:pb2", "w5:pb2")
function axpn:preceding-without-predicate-flwor() {
Expand Down Expand Up @@ -161,6 +180,25 @@ function axpn:following-with-predicate-db-map() {
! (./@id || ":" || (./following::pb[1]/@id, "FOLLOWING_PB_NOT_FOUND")[1])
};

declare
%test:assertEquals("w1:pb2", "w2:pb2", "w3:pb2", "w4:pb3", "w5:pb3")
function axpn:following-with-context-predicate-db-flwor() {
for $w in doc("/db/test/test.xml")//w[exists(.)]
let $following-page := $w/following::pb[1]
return
if ($following-page) then
$w/@id || ":" || $following-page/@id
else
$w/@id || ":FOLLOWING_PB_NOT_FOUND"
};

declare
%test:assertEquals("w1:pb2", "w2:pb2", "w3:pb2", "w4:pb3", "w5:pb3")
function axpn:following-with-context-predicate-db-map() {
doc("/db/test/test.xml")//w[exists(.)]
! (./@id || ":" || (./following::pb[1]/@id, "FOLLOWING_PB_NOT_FOUND")[1])
};

declare
%test:assertEquals("w1:pb2", "w2:pb2", "w3:pb2", "w4:pb3", "w5:pb3")
function axpn:following-without-predicate-flwor() {
Expand Down