[web] Small XSL problem

Started by
0 comments, last by Sander 16 years, 10 months ago
I'm having some trouble getting this to work:

<xsl:for-each select="borders">
   <xsl:value-of select="//country[@id=@country]/@name"/>
</xsl:for-each>


I'm trying to display all the "country"'s "@name" attribute which has their "@id" attribute equal to the "border"'s "@country" attribute. I hope I've made myself clear :) note each "country" has a unique "@id" attribute, so there should display one country/@name per loop in the for-each. thx
Advertisement
In:

//country[@id=@country]/@name

The country attribute '@country' is taken from the <country> element, not the <borders> element. What you need to do is, just before the value-of, assign the value of the <borders>'s @country attribute to an xsl:variable, then use that variable in the value-of.

See xsl:variable at http://www.w3.org/TR/xslt#variables

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement