XPath exists function is a good solution. It returns true if the value
is not an empty sequence.
https://www.w3.org/TR/xpath-functions-31/#func-exists
Best regards,
Christophe
Le 18/09/2022 C 10:05, Mukul Gandhi mukulg@xxxxxxxxxxxxxxxxx a C)critB :
> Hi Mark,
>
> On Wed, 31 Aug, 2022, 06:57 Mark Giffin m1879@xxxxxxxxxxxxx,
> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> XSLT 2.0, Saxon processor.
>
> What's a good way to check if a variable has a value? I want to
> print something if a variable has a value, and not print it if it
> is not given a value. This must be extremely simple but I don't
> see it.
>
>
> I think, we can simply compare XSLT 2.0+ variable's value with an
> empty sequence.
>
> i.e somthing like below,
>
> <xsl:if test="not(deep-equals($var, ()))">
> B B <xsl:copy-of select="$var"/>
> </xsl:if>
>
> (this will output the contents of variable to XSLT result tree, which
> the XSLT serializer could serialize to an XML fragment instance for
> example)
>
> or,
>
> <xsl:if test="not(deep-equals($var, ()))">
> B B <xsl: value-of select="diagnostic message"/>
> </xsl:if>
>
>
> --
> Regards,
> Mukul Gandhi
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe
> <http://lists.mulberrytech.com/unsub/xsl-list/3430162> (by email)
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2837134>
> (by email <>)
|