Reputation: 204766
I am parsing a XML file with different elements to build a CSV. I iterate through persons like this
<xsl:template match="/root/persons/person">
<xsl:for-each select=".">
<xsl:value-of select="name" />
<xsl:text>;</xsl:text>
<xsl:variable name="refId">
<xsl:value-of select="role/@refId"/>
</xsl:variable>
<!-- This is the problematic part -->
<xsl:value-of select="/root/roles/role[@id='$refId']"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
In my person element I have a refId that refers to the ID of a role element. How can I get the role name with the refId loaded into a variable like above?
Upvotes: 0
Views: 540
Reputation: 6437
Try using this:
<xsl:value-of select="/root/roles/role[@id=string($refId)]"/>
I'm supposing that your path is correct, since we can't see your XML to validate.
Upvotes: 1