[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: enclose output of transform in CDATA section

Subject: Re: enclose output of transform in CDATA section
From: Armen Martirossian <armmarti@xxxxxxxxx>
Date: Thu, 14 Aug 2003 05:43:55 -0700 (PDT)
generate cdata section with xsl
--- Dave Beattie <Dave.Beattie@xxxxxxxxxxx> wrote:
> Hi
> I have to produce an output file in the following
> format
> <Message>  
> 	<![CDATA[
> 		...xml document as generated from a transform in
> here ...
> 	]]> 
> </Message>
> Any suggestions as to how I go about doing this.
> Thanks
> Dave
I can suggest to use xsl:text with
disable-output-escaping="yes", though as discussed
many times the feature(d-o-e) is not supported by all
XSLT processors and must be avoided if possible.

However, to perform an identity transformation for
example, and put the result in the CDATA section, you
can do this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/">
	<xsl:template match="node() | @*">
			<xsl:apply-templates select="node() | @*"/>

But there is another potential problem here: in spite
of how you output(or generate) CDATA delimiters here,
the source XML can contain "]]>" sequence or even
during the transformation such sequence may be
generated and the result will not be well-formed
XML(CDATA section will contain forbidden "]]>"


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.