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

RE: Looking up elements with {@attname}

Subject: RE: Looking up elements with {@attname}
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 24 May 1999 09:54:55 +0100
looking for elements
> Klaas Bals [mailto:kbals@xxxxxxxxxxx] asked:
>I'll try to give a simplified example:
> 
> <element att2="same-value" att3="firstvalue"/>
> <element att2="same-value" att3="secondvalue"/>
> 
> <xsl:stylesheet>
>     <xsl:template match="element">
>         <xsl:value-of select="@att3"/>
>         <xsl:text> found </xsl:text>
>         <xsl:value-of select="//element[@att2={./@att2}]/@att3"/>
>     </xsl:template>
> </xsl:stylesheet>
> 
the curly-bracket notation can only be used in attributes that are defined
to be attribute-value-templates; the select attribute of xsl:value-of (and
all other attributes whose value is an expression) are not AVTs, so you
cannot use this mechanism.

Try:
>     <xsl:template match="element">
>	    <xsl:variable name="x" expr="@att2"/>
>         <xsl:value-of select="@att3"/>
>         <xsl:text> found </xsl:text>
>         <xsl:value-of select="//element[@att2=$x][2]/@att3"/>
>     </xsl:template>

I added the [2] because in your example you're looking for the second
element in which att2 has this value: I suspect this isn't quite right but
you haven't specified the problem in enough detail for me to do any better.

Alternatively, and probably more efficiently, use keys.

Mike Kay


 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.