In my xml i have a number of IDs and REF attributes.
Simplified under:
<library>
<book ID="123">
<author ref="33"></author>
<Info>Vulpes Vulpes, Canis Lupus</info>
<about>Programming</about>
</book>
<author ID="33">
<firstname>John</firstname>
<lastname>McLovin</lastname>
</author>
</library>
So I want to use a Xquery to extract out the info about the author, using the REF attribute under book.
for $x in library/book
where $x/about = "programming"
return data ($x/library/book/author/@ref)
With this method i extract the refnumber 33. But I want the data that ref="33" points to, which is located under ID="33". I would like firstname and lastname as result.
Is this possible? If not like this, how is it possible?
for $x in library/book
where $x/about = "Programming"
return data (library/author[@ID=$x/author/@ref])