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

XSLT 2.0 empty string

Subject: XSLT 2.0 empty string
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Mon, 28 Feb 2005 12:14:17 -0000
xslt empty string
Consider the following code:

<xsl:variable name="foo" select="nothing" as="xs:string?"/>

	<xsl:when test="$foo != ''">A</xsl:when>
	<xsl:when test="$foo = ''">B</xsl:when>
	<xsl:when test="not($foo != '')">C</xsl:when>

When there isn't a <nothing> element, the output is C.  That is:

$foo != '' is false


$foo = '' also is false

Which is strange.  If I do "$foo is empty" then Saxon tells me $foo is a
string and not a nodeset.  After adding the explicit cast, the test

string($foo) = ''

Which suggests that $foo isn't a string (so which is it?).  It almost as
if the empty nodeset doesn't get implicitly cast like a 'populated'
nodeset, and the as: attribute is ignored.  Is there a difference
between the way the two are handled?

Also, is using "!= ''" a bad way of checking if the variable has content
when the variable type is 'xs:string?' (ie optional)?


Current Thread


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.
First Name
Last Name
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.