I’m about to learn using Xquery with Tamino. Everything was going well so far but now I got stuck (although trying to get a solution for several hours…) Hope you can help me out, please.
I have XML-data containing some newspaper articles which has some text-elements. Now, I want to find the article(s) whose text-element contains the word “politics” and get as a result the text and the id-attribute of its article-element.
<issue> <article id="1"> <text>xxx xxx politics xxx xxx xxx</text> </article> <article id="2"> <text>xxx xxx xxx xxx xxx xxx</text> </article> </issue>
What I already have is an Xquery that gets all the text-elements which contain “politics” but not the id-attributes of their article-elements. How do I have to extend my xquery? Or is it a totally wrong way?
declare namespace ft="http://www.w3.org/2002/04/xquery-operators-text" for $q in input()/issue/article//text where ft:text-contains($q, "politics") return $q
Thanks a lot in advance!