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

RE: Treat CDATA section content as node

Subject: RE: Treat CDATA section content as node
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 25 Feb 2010 09:33:38 -0000
RE:  Treat CDATA section content as node
> So you might have:
> 
> <xyz><![CDATA[<p>a paragraph</p><p>a paragraph</p><p>a 
> paragraph</p>]]></xyz>
> 
> Maybe I want to tranlsate the <p> tags into <div> tags.

Well, there aren't any <p> tags. That's what CDATA means: "the stuff in here
might look like markup, but it isn't, it's ordinary character data". "<p>"
is therefore not a tag, it's a sequence of three characters. If the author
wanted it to be treated as markup, he shouldn't have put CDATA around it.

Unfortunately this misuse of CDATA is very common. The only way to deal with
it is to extract the string inside the CDATA (as a string) and then pass it
to an XML parser to convert into a tree that XSLT can process. That needs
calls to extension functions (unless you want to do the parsing in XSLT, of
course, which isn't likely to be much fun in XSLT 1.0).

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

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.