tags:

views:

28

answers:

1

I am trying to get the following output :

<name><![CDATA[ SomeNameHere ]]></name>

using the following xslt :

  <xsl:element name="name"> 
            <xsl:cdata>
                <xsl:value-of select="name"/> 
            </xsl:cdata>
  </xsl:element>

But while compiling I get the following exception :

'xsl:cdata' cannot be a child of the 'xsl:element' element.

How can I insert cdata elements inside an xml node then?

Thank you.

+2  A: 

There's no such think as <xsl:cdata>

If your <xsl:output/> includes name among the elements listed in the cdata-section-elements attributes, then it will use CDATA sections for all such elements.

If you needed it in one particular case, you could kludge with disable-output-escaping though really you shouldn't have any need for this.

Jon Hanna
Just as I said above. Have cdata-section-elements="name message" in your <xsl:output element>. (use prefix if appropriate).
Jon Hanna