xsl-list
[Top] [All Lists]

Re: [xsl] Wrapping content in a CDATA tag

2009-02-15 06:48:45
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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--