[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XPATH 1.0: Selecting an element attribute starting from a self:: attribute


Subject: Re: [xsl] XPATH 1.0: Selecting an element attribute starting from a self:: attribute
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Jun 2015 14:05:06 -0000

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.


Current Thread
Keywords