xsl-list
[Top] [All Lists]

Re: [xsl] XSLT2 test for null

2011-03-03 03:54:26
On 3 March 2011 09:44, Merrilees, David 
<David(_dot_)Merrilees(_at_)uk(_dot_)tesco(_dot_)com> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>