[xquery-talk] xpath1 text node contains attribute, equivalent in xpath2

e-letter inpost at gmail.com
Fri Dec 27 10:07:30 PST 2013

On 27/12/2013, Misztur, Chris <CMisztur at macleanfogg.com> wrote:
> Imagine that query [1] is actually doing a for-each loop on each <title/>
> and the predicate in square brackets is applying a 'where' statement on each
> iteration.  You can also rewrite query [1] as query [3].

The 'let' clause was chosen because it was not considered necessary to
perform any multiple iterations, just a single search for the target.
Is this an incorrect thought-process?

> [3] for $book-title in doc('xmldatabasefile.xml')/bookstore/book/title
>         Where contains($book-title/text(), 'Learning XML')
>         Return $book-title/text()

This is understood, but the request was also to retrieve the text
nodes of the parent (and parent siblings - uncles/aunts? or maybe
referred to as sibling text nodes? ;) ) elements, i.e.:

Learning XML
Erik T. Ray

I am unable to append sucessfully '/parent::*' to the 'for' statement above.

More information about the talk mailing list