|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Copy CDATA nodes from XML to XML format w/ XALAN
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








