I think that under certain conditions, the path() function does not return the proper paths.
Here’s an example that works ok:
for $doc in <doc><a/><b><c/></b></doc> let $nodes as element(*)* := xquery:eval("$doc//*", map{"doc":=$doc}) return for $node in $nodes return <result path="{path($node)}" name="{name($node)}"/>
⇒ <result path="Q{http://www.w3.org/2005/xpath-functions}root()/Q{}a[1]" name="a"/> <result path="Q{http://www.w3.org/2005/xpath-functions}root()/Q{}b[1]" name="b"/> <result path="Q{http://www.w3.org/2005/xpath-functions}root()/Q{}b[1]/Q{}c[1]" name="c"/>
Now I create a database 'doc' with the document 'doc.xml' and invoke the slightly modified query:
for $doc in db:open('doc', 'doc.xml')/* let $nodes as element(*)* := xquery:eval("$doc//*", map{"doc":=$doc}) return for $node in $nodes return <result path="{path($node)}" name="{name($node)}"/>
⇒ <result path="Q{http://www.w3.org/2005/xpath-functions}root()" name="a"/> <result path="Q{http://www.w3.org/2005/xpath-functions}root()" name="b"/> <result path="Q{http://www.w3.org/2005/xpath-functions}root()" name="c"/>
The element names are still known, but not their paths. Is it a bug or am I missing something?
Gerrit