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

RE: accessing CDATA from XSL

Subject: RE: accessing CDATA from XSL
From: Jarno.Elovirta@xxxxxxxxx
Date: Mon, 23 Dec 2002 09:36:39 +0200
accessing cdata
Hi

> > I have an xml file which has got a CDATA in it for eg:
> > <parent>
> > <child>.... </child>
> > < ! [ CDATA[ hi how r u .....]]>
> > </parent>
> >
> > so from my xsl i want to access the content of the CDATA
> > ie .. i how do i do that ie
> > <xsl:template match="Parent">
> > <xsl:value-of select="."/>
> > i want the CDATA value here
> > so how do i do that
> > mukund
> 
> <xsl:value-of select="text()"/> will return the text of the 
> parent element,
> without including the text of the <child> element.

That will select only whitespace. Instead use.

  <xsl:value-of select="text()[position() = last()]"/>

This however, also selects the line feeds after the child element and the last line feed inside parent; the XPath datamodel will not retain the CDATA section, but rather has a text node for it, with immediately preceding and following text nodes concatenated.
 
> In this context <xsl:value-of select="."/> is equivalent to:
> <xsl:value-of select=".//text()"

Again, that would select whitespace.

Cheers,

--

Jarno - Front Line Assembly: New Year's Day (U2 cover)

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


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.