Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the value of a variable in XSLT

Tags:

xslt

xslt-1.0

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.

like image 704
user1942634 Avatar asked Dec 06 '25 16:12

user1942634


1 Answers

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

like image 71
CodeGroover Avatar answered Dec 08 '25 07:12

CodeGroover



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!