xquery version "3.1";
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
declare namespace inspect = "http://exist-db.org/xquery/inspection";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:indent "yes";
declare variable $local:XML := document {
<doc><div n="outer"><head>x</head><div n="inner"><head>x</head><p>y</p></div></div></doc>
};
declare variable $local:COLL := "/db/test-nested-predicate";
declare %test:setUp function local:setup() {
xmldb:create-collection("/db", "test-nested-predicate"),
xmldb:store($local:COLL, "test.xml", $local:XML)
};
declare %test:tearDown function local:tearDown() {
if (xmldb:collection-available($local:COLL)) then xmldb:remove($local:COLL) else ()
};
declare %test:assertEquals("outer", "inner") function local:in-memory() {
$local:XML//div[.//p[. = "y"]] ! string(@n)
};
declare %test:assertEquals("outer", "inner") function local:stored() {
doc($local:COLL || "/test.xml")//div[.//p[. = "y"]] ! string(@n)
};
test:suite(inspect:module-functions())
Export this post to PDF document