Re: [xsl] Checking if a variable has a value

Subject: Re: [xsl] Checking if a variable has a value
From: "Mukul Gandhi mukulg@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 18 Sep 2022 08:05:09 -0000
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

i.e somthing like below,

<xsl:if test="not(deep-equals($var, ()))">
    <xsl:copy-of select="$var"/>

(this will output the contents of variable to XSLT result tree, which the
XSLT serializer could serialize to an XML fragment instance for example)


<xsl:if test="not(deep-equals($var, ()))">
    <xsl: value-of select="diagnostic message"/>

Mukul Gandhi

XSL-List info and archive <>
> EasyUnsubscribe <> (by
> email <>)

Current Thread