XSL - Passing data as attribute value of tag
For example, you have data like this :
<sometag SomeAttribute="some value" />
You want to make value of SomeAttribute
as variable that accessible from HTML tag atrribute value. Like <div class="value of SomeAttribute"></div>
.
You can use xsl:param
. For example, I'm assigning SomeAttribute
value to some variable called somevar
. The code would be :
<xsl:param name="somevar" select="sometag/@SomeAttribute" />
Normally, to get somevar
value, we use :
<xsl:value-of select="$somevar"/>
But to use it as attribute value, we can use :
<div class="{$somevar}"></div>
Written by Noval Agung Prayogo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Xml
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#