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

Re: Using condition expression with an empty string va

Subject: Re: Using condition expression with an empty string variable
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 21 Jun 2001 13:02:36 +0100
xsl empty expression
Hi Sun-fu,

> I have applied the following condition expression successfully to my
> job. And this expression pattern is suggested by Jeni back in May
> xsl list.(msg00890.htm)
>
>    [@FacilityID[string($office)]=$office]
>
>   which   is supposed to handle situations as:
>   when variable **office** is a given string,  then the condition will be
> applied.
>   when variable **office** is an empty string, then the condition will not
> be used.
>
> Now I try to apply the expression to a simple case like example
> below, it does not function correctly for the given empty string, it
> produces a set of empty nodes instead. Why?

I think it's because the left hand side is an empty node set, being
compared against an empty string. When a node set is compared for
equality against a string, then it returns true only if there's a node
whose value is equal to that string.  With an empty node set, that's
never the case.

I think that in the other situations you must have been doing
something to convert the empty node set into an empty string (e.g.
using substring() or translate() on it).  When the two empty strings
were compared, then that returns true.

The solution is to force the conversion of the empty node set to a
string using the string() function:

    string(@FacilityID[string($office)]) = $office

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.