This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Using condition expression with an empty string variable
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Using condition expression with an empty string variable
- From: "Yang" <sfyang at unisvr dot net dot tw>
- Date: Thu, 21 Jun 2001 19:20:56 +0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
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?
Would anyone provide some suggestions?
** xml **
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<docs>
<z-row FacilityID="xxx" ProductID="aaa"/>
<z-row FacilityID="yyy" ProductID="bbb"/>
<z-row FacilityID="zzz" ProductID="ccc"/>
</docs>
** xsl ***
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="office" select="''"/> <!-- input an empty string -->
<xsl:variable name="xx"
select="//z-row[@FacilityID[string($office)]=$office]"/>
<xsl:copy-of select="$xx"/>
</xsl:template>
</xsl:stylesheet>
Thanks.
Sun-fu Yang,
sfyang@unisvr.net.tw
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list