How to access variable in CDATA from XSLT?

Amit picture Amit · Feb 15, 2010 · Viewed 12.8k times · Source

I am using XSLT Transformation and need to put some data in CDATA section and that value is present in a variable.

Query: How to access variable in CDATA ? Sample Given Below:

<xsl:attribute name ="attributeName">
<![CDATA[ 
  I need to access some variable here like
   *<xsl:value-of select ="$AnyVarible"/>* 
 ]]>
</xsl:attribute>

How can I use varibale in CDATA ? Note: I can not use --> &lt;![CDATA[<xsl:value-of select ="$AnyVarible"/>]]&gt; Thanks in advance.

Answer

Amit picture Amit · Feb 15, 2010

I got the solution for this...FYI for everyone...

<xsl:text
disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
<xsl:value-of select ="$AnyVarible"/>
<xsl:text
disable-output-escaping="yes">]]&gt;</xsl:text>