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

Re: choose - when problem

Subject: Re: choose - when problem
From: Mike Brown <mike@xxxxxxxx>
Date: Sun, 11 Feb 2001 17:09:20 -0700 (MST)
Re:  choose - when problem
Jo Kong HO wrote:
> Having a little problem with choose - when.  I having trying to test wether
> a node is having the value of "True" or "False".
> 
> Given the following xslt segment, and I know the selected node value is
> "True". The following test seems to returns false.
> 
> <xsl:choose>
> 	<xsl:when test=".='True'">
> 		Y
> 	</xsl:when>
> 	<xsl:otherwise>
> 		N
> 	</xsl:otherwise>
> </xsl:choose>

This looks fine, so the problem is either:

- the current node is not the one you think it is; or

- the string value of the current node really isn't 'True'
   (caused by whitespace around the string, or more descendant text
    nodes); 

For example, if the current node is the element 'foo' below...

	<foo>
	True
	</foo>

...then its string value is (using \n to represent newline chars for
readability here.. use &#10; in your code):

	\nTrue\n

...so you would want test for "normalize-space(.) = 'True'".

Second, if the current node is element 'foo' and you have something like

	<foo>
          True
	  <bar>Hi!</bar>
	  <baz>123</baz>
	</foo>

...then the string value is

	\n  True\n  Hi!\n  123\n

And finally, if your example is not accurate and you are actually testing
something like

	<xsl:when test="/path/to/some/nodes = 'True'">

or

	<xsl:variable name="some_nodes" select="/path/to/some/nodes"/>
	<xsl:when test="$some_nodes = 'True'">

...then the test will succeed as long as *any* of the 'nodes' elements
have the string value 'True'.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at            My XML/XSL resources: 
webb.net in Denver, Colorado, USA              http://skew.org/xml/


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


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.