xsl-list
[Top] [All Lists]

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

2015-06-17 09:05:21
Malecki, Piotr piotr(_dot_)malecki(_at_)thyssenkrupp(_dot_)com 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.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>