This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: checking for element in CDATA


Hello,

A CDATA section is treaten as a normal text node. So the stylesheet returns
the text in the CDATA section.
On the returned text you can use the contains() method to check if your text
is available.

So you could use:
	<?xml version="1.0"?>
	<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

	<xsl:template match="/">
		<xsl:apply-templates select="element/example"/>
	</xsl:template>
	
	<xsl:template match="element/example">
		<xsl:variable name="CDATASection">
			<xsl:value-of select="text()"/>
		</xsl:variable>
		<xsl:if
test="contains($CDATASection,'&lt;ArticleHistory&gt;')">
			TRUE
		</xsl:if>
	</xsl:template>
	</xsl:stylesheet>

Kind regards,
Ismaël

-----Original Message-----
From: Srinivas Ch [mailto:sideburnch@yahoo.com]
Sent: Tuesday, August 27, 2002 11:22 AM
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] checking for element in CDATA


Hallo everyone,
I have write a xsl to check if there is an element
present in CDATA, how to do this.
Here is an example
<element name="ArticleHistory">
   <example><![CDATA[<ArticleHistory>
      <RegistrationYear>2001</RegistrationYear>
      <Received>
         <Year>1999</Year>
         <Month>9</Month>
         <Day>7</Day>
       </Received>
   </ArticleHistory>]]>
  </example>
</element>

so here I have to check if <ArticleHistory> is present
inside CDATA.
How to do this?
Thanx,
Sri


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

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

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]