Subject: RE: [xsl] ACCESSING SPECIFIC CDATA FIELD From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 13 Dec 2005 15:21:48 -0000 |
> I've one XML and trying to access the specific CDATA on XML There's no such thing as a CDATA node in the XPath data model: the text that you write in CDATA sections in your input ends up in ordinary text nodes. But that's not directly relevant to your problem. > but when do > this, I capture all CDATAs nodes. See the XML and XSL code bellow: > > // -----------------------------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"> Should I be reading this as select="scripts/etps/etp"? > <tr valign="top"> > <td comment="ETP"> > <xsl:value-of select="."/> "." here gives you the string value of the context node (which is an element): the string value of an element is the concatenation of all its descendant text nodes. If you just want the value of the first child text node, use select="text()[1]". Note however that this will give you the whitespace characters that were outside the CDATA section as well as the characters that were within it - there's no way of separating the two. Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] ACCESSING SPECIFIC CDATA , Nick Fitzsimons | Thread | [xsl] Multi -step processing in a f, Agnisys |
Re: [xsl] ACCESSING SPECIFIC CDATA , Jon Gorman | Date | [xsl] Multi -step processing in a f, Agnisys |
Month |