[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Looking up elements with {@attname}
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|