I'm stuck with a small problem.
The XSL-File:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:template match="/">
<xsl:variable name="unumericValue" select="10" />
<xsl:variable name="uanotherValue" select="8" />
<xsl:for-each select="/root/try">
<xsl:value-of select="var" />
<xsl:variable name="min"><xsl:value-of select="@minimum" /></xsl:variable>
<xsl:value-of select="@type" />
<xsl:variable name="referenceName"><xsl:value-of select='concat("u",var)' /></xsl:variable>
<xsl:value-of select="$referenceName" />
<xsl:if test='$referenceName > $min'>
<p>Do something.</p>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The XML File:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="q1.xsl"?>
<root>
<try type="compare" minimum="9">
<var>numericValue</var>
<something>...</something>
</try>
<try type="compare" minimum="10">
<var>anotherValue</var>
<something>...</something>
</try>
</root>
As you can see the XML file has two var-Elements which should match to the variables in the XSLT-File. However I don't know which Syntax is correct. $referenceName is just the name of the variable which I want to use. But I don't know how to reference the name to the existing variable.
See Question&Answers more detail:os