"Jean-Paul Rehr rehrjb@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
writes:
> In Xquery the following returns false:
>
> let $x := ()
> return
> if (exists($x)) then true() else false()
>
> Are you stating that the equivalent cannot happen in XSL variables?
> I'm asking this mostly because I've not had the need to explore this
> until now and am ignorant about it.
It can, if the value of the variable is the empty sequence. Consider
this stylesheet:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:param name="x" select="()"/>
<xsl:template name="xsl:initial-template">
<exists>
<xsl:choose>
<xsl:when test="exists($x)">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</exists>
</xsl:template>
</xsl:stylesheet>
It will output b<exists>false</exists>b by default, but will output
b<exists>true</exists>b if you specify a value for $x, even the empty
string.
Be seeing you,
norm
--
Norman Tovey-Walsh <ndw@xxxxxxxxxx>
https://nwalsh.com/
> Where it is permissible both to die and not to die, it is an abuse of
> valour to die.--Mencius
[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]
|