[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: catch from another node with the same id (NEWBIE)

Subject: RE: catch from another node with the same id (NEWBIE)
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Tue, 10 Sep 2002 12:10:39 +0100
RE:  catch from another node with the same id (NEWBIE)
Hi Thomas
[snip]
> 
> instead of the "id" i need the product name (bezeichnung) which is 
> stored in a completly different node "/page/info/produkte/" 
> but with the 
> correspondending "id"
> <page>
>   <info>
>    <produkte>
>     <produkt id="1" bezeichnung="Produkt A">
>      <text>Produktebeschrieb A</text>
>     </produkt>
>     <produkt id="2" bezeichnung="Produkt B">
>      <text>Produktebeschrieb B</text>
>     </produkt>
>     <produkt id="3" bezeichnung="Produkt C">
>      <text>Produktebeschrieb C</text>
>     </produkt>
> ........
>    </produkte
>   </info>
> </page>
> 
> can I use some kind of variable to do it? Or how do I get the 
> correspondending "bezeichnung" attribute from the other node?
> Any hints?

Close - but you want a key rather than a variable.

Declare the key outside of any template.

<xsl:key name="productNameByID" 
	match="info/produkte/produkt" 
	use="@id"/> 

This will let you "catch" nodes in the document that are matched
by the match expression, using their id attribute.

You use the key inside your for-each like so:
 <fo:block>
    <!--  <xsl:value-of select="@id"/>  -->
	<xsl:value-of select="key('productNameByID',@id)/@bezeichnung"/>
   </fo:block> 

Keys also speed things up considerably and are used for grouping.

Have fun.
Tom

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.