Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

[web] Small XSL problem

This topic is 4160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!