XSL: matching variable to XML attribute

wxdqz

New Member
XML:

<occurence id="1" />
<occurence id="2" />

XSL:

<xsl:param name="language"/>

<xsl:variable name="ranges">
<range id="1">
<name xml:lang="en">British Columbia</name>
<name xml:lang="fr">Colombie-Britannique</name>
</range>
...
</xsl:variable>


I want to be able to loop occurence and display the matching value from the variable. I have been wrestling all afternoon with this.

So far:

<xsl:template match="occurence">
<xsl:value-of select="$ranges/range[id(occurence/@id)]/name[lang($language)]" />
</xsl:template>


I keep getting this error:

The cause of this exception was that: AutomationException: 0x80004005 - Expression must evaluate to a node-set. -->$ranges<--/range[id(occurence/@id)]/name[lang($language)] in 'msxml4.dll'
 
Back
Top