Issue
Compare two nodesets for equality using xquery
Resolution
Use a recursive function to runa deep-equal() function across all nodes
Xquery
declare function utils:deep-equal($node1 as element(), $node2 as element()) as xs:boolean {
let $equal as xs:boolean := deep-equal($node1, $node2)
return (
if (not($equal) or empty($node1/*)) then $equal
else (
every $de in (
for $n in $node1/*
let $position := count($n/preceding-sibling::*)+1
return utils:deep-equal($n, $node2/*[$position])
)
satisfies $de = true()
)
)
};
No comments:
Post a Comment