declare namespace form="http://rules.labs.bt.com/form"; (: Function which tests node identity for various xpath sequences:) declare function local:testis($needle as node(), $haystack as node()*){ if(some $hay in $haystack satisfies $hay is $needle) then 'true' else 'false' }; let (: The constructed tree :) $input := here's some text and some extra text , (: Various sequences constructed from the constructed tree, within which identity is tested :) $keepall := $input//(*|@*|text()), (: Works in eXist :) $keepelsatts := $input//(*|@*), (: Works in eXist :) $keepelsnamed := $input//(self::container|self::form:warning), (: Works in eXist :) $keepelsonly := $input//*, (: Busted in eXist - nothing preserved :) $keepoutsidenamespace := $input//(*|@*|text())[not(self::form:*)] (: Busted in eXist - nothing preserved :) (: The report from each calculated sequence indicating which sequences the original root node can be found in :) return

All: {local:testis($input,$keepall)}

Elements and Attributes: {local:testis($input,$keepelsatts)}

Elements named: {local:testis($input,$keepelsnamed)}

Elements only: {local:testis($input,$keepelsonly)}

Elements outside namespace: {local:testis($input,$keepoutsidenamespace)}