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

Re: ACCESSING SPECIFIC CDATA FIELD

Subject: Re: ACCESSING SPECIFIC CDATA FIELD
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Tue, 13 Dec 2005 09:17:52 -0600
nvgs for sale
On 12/13/05, viniciuscamara@xxxxxxxxxxxx <viniciuscamara@xxxxxxxxxxxx> wrote:
> Hello Fellows,
> I've one XML and trying to access the specific CDATA on XML but when do
> this, I capture all CDATAs nodes. See the XML and XSL code bellow:

First of all, there is no such thing as a CDATA node.  CDATA is just a
nice way to write something so that you don't have to worry about
escaping all the < and other special characters.  There's only text
nodes.  So what you really appear to be asking for is a way to select
specific text nodes.

And the answer is yes, of course.  Just select the text nodes and
apply-templates or get their value.


>  // -----------------------------xml -----------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <scripts>
>    <etps total="1">
>        <etp id="200">
>            <![CDATA[Trying accessing only this]]>
>            <nvgs>
>                <nvg id="201"><![CDATA[blablablablabla]]></nvg>
>                <nvg id="202"><![CDATA[blablablablabla]]></nvg>
>            </nvgs>
>        </etp>
>    </etps>
> </scripts>
>
>  // -----------------------------xsl -----------------------------
> //code's resume
> <xsl:choose>
> <xsl:when test="scripts/etapas/@total>0">
> <table width="100%" id="SCRIPT">
>    <tr valign="top" style="font-weight:bold;">
>        <th width="40%">etp</th>
>        <th width="20%">nvg</th>
>    </tr>
>
> <xsl:for-each select="scripts/etapas/etapa">
>   <tr valign="top">
>        <td comment="ETP">
>            <xsl:value-of select="."/><br/> <!--When I put the prefix "."
>             <!--the XSL return all CDATA nodes, including "nvgs"-->

No, it gets the value of the element, which is defined in the specs.
A quick summary would be all the text nodes of this element and all
the text nodes of its descendents.  If you don't want to do that, get
<xsl:value-of select="text()" /> although my guess in this case you
want to get <xsl:value-of select="text()[1]" />.   (or just
apply-templates on those if you do anything special with the text).



> Is it necessary to create a node to CDATA ?
No, since it'll be turned into just escaped text via the parser.  As
far as the processor is concerned, it's just a typical text node.

Jon Gorman

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.