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

Re: Testing strings for null

Subject: Re: Testing strings for null
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 9 Jan 2001 09:34:20 +0000
xslt test for null
Hi Paul,

>         <xsl:when test="ASTRING $igt$ 0">

That syntax isn't XSLT syntax - it looks like you're using the old
MSXSL syntax.  Have a look at
http://www.netcrucible.com/xslt/msxml-faq.html to find out about it.

The correct syntax for the test in XSLT is:

   ASTRING > 0

This tests whether any of the ASTRING elements in your XML source have
a string value greater than 0.  If you have an ASTRING element that
looks like:

  <ASTRING>3</ASTRING>

then it'll return true.  If none of the ASTRING elements have
numerical values, then it will return false.

> I just want to know if ASTRING is null, and I can't seem to figure
> out what to do. This test comes up False every time.

By finding out whether ASTRING is null, do you mean whether there are
any ASTRING elements or whether the value of the ASTRING element is an
empty string?

To test whether there are any ASTRING elements, use, simply:

  ASTRING

This will return true if there are any ASTRING elements, false if
there are not.

To test whether there are any ASTRING elements that have a value that
is not the empty string, you can use:

  ASTRING[string(.)]

This will return true if there are any ASTRING elements that have a
value, and false if there aren't.

If you've only got one ASTRING element child in the current context
and you want to test whether it has a value, you can use:

  string(ASTRING)

This will return true if the ASTRING element has a value, false if it
doesn't.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.