Subject: Re: [xsl] Using condition expression with an empty string variable From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 21 Jun 2001 13:02:36 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Using condition expression wi, Yang | Thread | [xsl] Microsoft Encoding Problem, Ruairi |
[xsl] Using condition expression wi, Yang | Date | [xsl] Microsoft Encoding Problem, Ruairi |
Month |