Re: [xsl] Wrapping content in a CDATA tag

Subject: Re: [xsl] Wrapping content in a CDATA tag
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sun, 15 Feb 2009 12:48:17 +0100
Chad Chelius wrote:
Thanks for your reply Martin. Forgive me for not understanding this as I am not very skilled using XSLT. Can you supply me with a basic example as to how this is used in a sample xml file? Thanks for your understanding!

As said, use the cdata-section-elements attribute on your xsl:output element e.g.

 <xsl:output
   cdata-section-elements="field"/>

You need to put that xsl:output element into your stylesheet <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

    <xsl:output method="xml"
                cdata-section-elements="field"/>

</xsl:stylesheet>

'field' is the name of the element whose content you want to be serialized as a CDATA section. If you have several such elements then separate the names with spaces e.g.

    <xsl:output method="xml"
                cdata-section-elements="field foo bar"/>
--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread