From: <viniciuscamara@xxxxxxxxxxxx>
Date: Tue, 13 Dec 2005 14:47:44 -0300
Thanks Jon and friends,
for your explanation about CDATA nodes.

Well, I tried to use your idea "<xsl:value-of select="text()[1]" />" to access the text inside the node <etp id="200"> (see the code bellow), and spected this return: "Trying accessing only this", but returned empty to me.

When I put the prefix "." return to me "Trying accessing only this" + "blablablablabla" + "blablablablabla", with your descedents.

Is it necessary to use the node to separate the texts inside the node? Well, refferering your explanation I think not.
Are there another choice?

My code are parsed using Javascript and open it at Firefox.

Thank again.
Best regards

----- Original Message ----- From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, December 13, 2005 12:17 PM

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"?>
   <etps total="1">
       <etp id="200">
           <![CDATA[Trying accessing only this]]>
               <nvg id="201"><![CDATA[blablablablabla]]></nvg>
               <nvg id="202"><![CDATA[blablablablabla]]></nvg>

 // -----------------------------xsl -----------------------------
//code's resume
<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>

<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

_______________________________________________________ Yahoo! doce lar. Faga do Yahoo! sua homepage.

Current Thread