Malecki, Piotr piotr.malecki@xxxxxxxxxxxxxxxx wrote:
<library>
<catalog>
<book id="_1" name="Book1"/>
<book id="_2" name="Book2"/>
<book id="_3" name="Book3"/>
</catalog>
<customer>
<borrowed bookId="_1"/>
<borrowed bookId="_2"/>
</customer>
</library>
In an appplication (Windows WPF / XAML), my execution context is e.g.
the element "borrowed" (e.g. <borrowed bookId="_1"/>).
I have to find the name of the book which is referenced as bookId.
So my XPATH expression is like:
"//book[@id=self::*/@bookId]/@name"
Read as: give all books whose id equals to the bookId of the current node.
The context node inside of the predicate
[@id = self::*/@bookId]
is the "book" element so both
@id
as well as
self::*
are evaluated with the "book" element as the context node and
self::*
simply selects that "book" element.
|