Subject: Re: [xsl] boolean(string(false())) is true - always? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 2 Mar 2017 15:19:14 -0000 |
<xsl:function name="dy:isFoo" as="xs:boolean"> <xsl:param name="node" as="node()"/> <xsl:choose> <xsl:when test="$node[self::bar/@foo = 'x']"> <xsl:value-of select="true()"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="false()"/> </xsl:otherwise> </xsl:choose> </xsl:function>
and changed that to the more elegant:
<xsl:function name="dy:isFoo" as="xs:boolean"> <xsl:param name="node" as="node()"/> <xsl:sequence select="exists($node[self::bar/@foo = 'x'])"/> </xsl:function>
BUT then I looked at my old code and said to myself: This could never have worked?!
Isn't xsl:value-of creating a text node, so in xsl:otherwise it creates 'false'. And if this is cast to boolean as the function requires, we should get true(), because the string is not empty?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] boolean(string(false())) is t, Michael Müller-Hille | Thread | Re: [xsl] boolean(string(false())) , Sewell, David R. (dr |
[xsl] boolean(string(false())) is t, Michael Müller-Hille | Date | Re: [xsl] boolean(string(false())) , Sewell, David R. (dr |
Month |