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

RE: contains()

Subject: RE: contains()
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Tue, 10 Sep 2002 09:33:55 +0100
xsl and contains
Hello Alia

	The simple answer is either to replace 
		"contains(child::text(),'Euro')"
	with
		"contains(.,'Euro')"
	or to use <xsl:strip-space> to remove whitespace nodes.

	The whole node evaluated in string context will be all its
text nodes put together. You can see this if you were to try this:

	<xsl:for-each select="child::text()">
      	<child><xsl:value-of select="."/></child>
	</xsl:for-each>
	<total><xsl:value-of select="."/></total>

	The reason your original test worked sometimes is that in those
cases the first text node was the text you wanted, not whitespace;
whereas in this case there's a text node containing just whitespace - 
a linefeed in fact - and being the first node, it's the one that's
evaluated by "child::text()".

Tom

---



> -----Original Message-----
> From: Alia Mikati [mailto:Aliam@xxxxxxxxxxxxxxxxxxxx]
> Sent: 10 September 2002 09:10
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  contains()
> 
> 
> Hello,
> I hope u can help me with this. I have this part of an xml file:
>      ...
>      <tr class="dynamic_row1">
>         <td width="160px">
>         <img border="0" src="mypictures/flags/euro.gif" width="21"
>         height="13" />
>         ?Euro</td>
>         <td width="50px" class="dynamic_right">1.018</td>
>         <td width="50px" class="dynamic_right">1.018</td>
>         <td width="50px" class="dynamic_right">08:10</td>
>         <td width="90px" class="dynamic_center">09 SEP 2002</td>
>       </tr>
>       ...
> 
> And I wanna get the sibling value of the row containing 
> 'Euro'. But the 
> xsl template is not working as if it can't find 'Euro'. 
> ...
> <xsl:template match="body/center/table/tr/td">
>   <xsl:if test="contains(child::text(),'Euro')">
> 	<b> Bid value is :  </b> 
> 	<xsl:value-of select="normalize-space(following-sibling::td
> [position() = 1])"/><br/><br/>
> 	<b> Ask value is :  </b> 
> 	<xsl:value-of select="normalize-space(following-sibling::td
> [position() = 2])"/><br/><br/>
>   </xsl:if>
> </xsl:template>
> ...
> 
> It works if instead of 'Euro' I searched for '1.018' for exp. or any 
> other row value. I think the problem is the space before the 
> word 'Euro'. 
> I used 'normalize-space' but didnt work either. How can I fix it?
> Thx a lot
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

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


Current Thread
  • contains()
    • Alia Mikati - Tue, 10 Sep 2002 04:07:30 -0400 (EDT)
      • <Possible follow-ups>
      • Jarno . Elovirta - Tue, 10 Sep 2002 04:27:15 -0400 (EDT)
      • TSchutzerWeissmann - Tue, 10 Sep 2002 04:42:29 -0400 (EDT) <=

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.