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

Re: Handling CDATA element

Subject: Re: Handling CDATA element
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 09 Feb 2006 11:34:03 -0500
cdata elements
At 2006-02-09 17:21 +0100, Thorsten Scherler wrote:
I have a question regarding the CDATA element.

CDATA isn't an element, it is merely syntactic sugar for the human reader and does not impact on the *information* in the XML document.


XSLT and XPath, therefore, do not distinguish any information marked up using the CDATA syntactic construct.

<description><![CDATA[html-to-document.xsl no longer converts content to
an XDoc. Instead it renders converts documents to XDoc, instead it
allows H1, H2 etc. elements to pass through.
<br>

<br>
]]></description>

Fine ... that is just a bunch of text that happens to have a bunch of angle brackets.


Now in my xsl I have something like the following to preserve the markup
of the cdata (it can contain any html markup).
...
<xsl:value-of select="description" disable-output-escaping="yes" />
...

Fine, but that is merely indicating to the serialization that the sensitive markup characters are not to be escaped. Which cannot be used in an XML result, but can surely be used in an HTML result, which supports your use of any HTML markup in the information.


If you remove @disable-output-escaping then it will transformed to
&lt;br&gt;

Correct, in order to escape the sensitive markup characters.


That looses the markup information but result in well-formed markup.

"loses"? No, the angle brackets are all still there, they are just escaped ... and using disable-output-escaping on those angle brackets will produce the same HTML result as using disable-output-escaping on information captured using CDATA markup.


I prefer well-formed over well-presented, but best would be both. ;-)

"presented"? Do you mean in the XML document's text content? I'm guessing perhaps you mean that you want to see "<" instead of "&lt;" in the text content of your XML document, probably because human eyeballs are looking at it.


I am unsure how to fix that, has somebody an idea?

Fix what? I'm not sure where your problem is.


Note that if you wanted your XML transformation for all <description> elements to be serialized using a CDATA section, that is available in <xsl:output> using the cdata-section-elements="description" attribute.

TIA for any informations

I hope this helps.


. . . . . . . . . . . . Ken

--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-03-13/17
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.