XQuery / XPath: How to retrieve an attribute value from an ancestor node when computing two node-sets?



In an XQuery file, I have the following FLWOR expression:



xquery version "3.0";
...
for $file in collection($collection_path),
$path_to_hyperlemma in $file//(entry | cit)/form[@type='hyperlemma']/orth [ft:query(., $searchphrase)]
let $entry_number := $path_to_hyperlemma/../../@xml:id
return
....


$entry_number is supposed to store the attribute of a node higher up in the document. What makes it complicated is the use of the | operator in the second part of the for clause ($path_to_hyperlemma), because the node-sets I'm referring to with (entry | cit) are on different levels.


How do I get the attribute value of both node-sets?


Another question: I know that the use of // is not ideal performance wise. But if I replace // with the absolute path, I don't seem to be able to refer to node-sets on different levels. Is it at all possible to set the absolute path in this case?


No comments:

Post a Comment