Reputation: 73
Can anyone help me to create a map using dynamic variable value as a key in XSLT 1.0
I have a variable addressID
whose value is 123. I would like to use this as a key in a map
<xsl:value-of select="$addressID" /> // gives output 123
<my:map>
<entry key="$addressID">1</entry>
</my:map>
Please suggest me the proper syntax to use a variable in key.
Upvotes: 3
Views: 739
Reputation: 12154
CodeGroover is right, and you can also use attribute
provided example below
<my:map>
<entry>
<xsl:attribute name="key">
<xsl:value-of select="$addressID"/>
</xsl:attribute>
<xsl:value-of select="'1'"/>
</entry>
</my:map>
Upvotes: 0
Reputation: 2187
First, setup variable:
<xsl:variable name="addressID">123</xsl:variable>
Second, you can use it as follow:
<my:map>
<entry key="{$addressID}">1</entry>
</my:map>
via http://www.w3.org/TR/xslt#variables
Upvotes: 3