xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Copy CDATA nodes from XML to XML format w/ XALAN


Subject: Re: [xsl] Copy CDATA nodes from XML to XML format w/ XALAN
From: Mike Brown <mike@xxxxxxxx>
Date: Sun, 3 Mar 2002 15:02:21 -0700 (MST)

Peter Carlson wrote:
> I am trying to transform XML to XML with included CDATA and keep that CDATA
> node enclosed with a CDATA tag.

This is a FAQ. 

First a bit of scolding.

The role of an XML parser is to read the bits & bytes of an encoded XML
document and then consistently report to the application the logical contents
of the document. The logical contents are the canonicalized character data,
arranged into a hierarchy of named elements and attributes, mostly.

A CDATA section is an XML document's way of saying to an XML parser "this text
might look like markup, but it's really just a string of character data.
Report it to the application as you would any other character data." It simply
gives the XML document author a way to avoid having to escape all the "&" and
"<" characters in that span of text.

A CDATA section does *not* cause the text to be flagged in any special way
when it is reported to the application (the XSLT processor). The character
data in a CDATA section is reported to the application exactly the same way a
span of escaped character data would be reported.[*] The application has no
idea whether this character data came from a CDATA section or a separate
entity; it shouldn't need to.

See also http://www.dpawson.co.uk/xsl/sect2/cdata.html

Now that that's out of the way, to answer your question, add a 
cdata-section-elements attribute to your xsl:output element, like this:

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

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  personal: http://hyperreal.org/~mike/


 [*] However, a parser might report CDATA sections as separate spans of text 
     from any adjacent spans of escaped text / other CDATA sections.

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



Current Thread
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor