Re: [xsl] XSLT2 test for null

Subject: Re: [xsl] XSLT2 test for null
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Thu, 3 Mar 2011 09:54:17 +0000
On 3 March 2011 09:44, Merrilees, David <David.Merrilees@xxxxxxxxxxxx> wrote:
> Hi
>
> In XSLT2, how should I test for null, or empty parameters? For example, if I have <xsl:param name="routeValues" as="node()?" /> how should I test whether a value has been passed, or whether it's empty?
>

Typical you can just do:

test="$routeValues"

or be more explicit:

test="exists($routeValues)"

or depending on what gets passed in:

test="$routeValues/node()"

for structures or

test="normalize-space($routeValues)

to handle the case of the empty string being passed in.

-- 
Andrew Welch
http://andrewjwelch.com

Current Thread