CDATA With XSLT
In an XML file you can use CDATA to tell the parser that anything inside the CDATA element is your text data and not XML formatting. In a sense, you can use CDATA to escape data that looks like XML. See Escape From XML. For example, you can escape the ampersand like this:
&
or by using CDATA as in:
<![CDATA[ & ]]>
I often work with XML and XSLT so when I want to treat a block of HTML as data I use the CDATA element in my XML file that will later be transformed with an XSL. For example, in my XML I might have something like this:
<![CDATA[ <b>this is bold</b> ]]>
In my XSL file, I need to disable the data from being escaped by using the disable-output-escaping of the xsl:value-of tag as in:
<xsl:value-of select="." disable-output-escaping="yes"/>
If you forget the disable-output-escaping attribute the contents of the CDATA will be escaped, for example < will be transformed to <. With the disable-output-escaping attribute set to yes, the contents from the CDATA will not be escaped and treated as is.