Search code examples
xsltcdata

How to access variable in CDATA from XSLT?


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.


Solution

  • 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>