Sign in to follow this  
johnnyBravo

[web] Small XSL problem

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this