Re: [xsl] shortest way to write this xsl:if statement

Subject: Re: [xsl] shortest way to write this xsl:if statement
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Fri, 15 Jun 2012 14:22:13 +0100
> = as Ken has very patiently described is an existential quantifier. If
> you want regular equality testing use eq.
>
> There are two categories of XPath comparators. General comparison
> operators like = that do existential quantification and value
> comparison operators like eq that compare atomic values.

One thing to be aware of is you have to be careful when using eq when
the sequence type is xs:boolean, for example:

<xsl:variable name="foo" select="/aaa eq '123'" as="xs:boolean"/>

will fail with an exception if /aaa returns the empty sequence. However:

<xsl:variable name="foo" select="/aaa = '123'" as="xs:boolean"/>

...will succeed as when you use = if either side is the empty sequence
it returns false, and not ()



-- 
Andrew Welch
http://andrewjwelch.com

Current Thread