[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How can you tell if a variable exists?

Subject: Re: How can you tell if a variable exists?
From: "Scott Sanders" <scott@xxxxxxxxxxxx>
Date: Wed, 20 Oct 1999 08:49:03 -0700
xsl variable exists
> > How can you tell if a variable exists (or rather does not
> > exist), without erroring out of the stylesheet.
> >
> Referring to $v when there is no <xsl:param name="v"> or <xsl:variable
> name="v"> in scope is an error, and you can't trap this. But referring to
$v
> when there is a declaration of <xsl:param name="v"> should not give an
> exception, whether or not the parameter has been given a value.
>
> From the description of your problem, I would declare a global parameter
>
> <xsl:param name="v"/>
>
> and then in your code you can do
>
> <xsl:choose>
> <xsl:when test="not($v)"> <!-- parameter has not been supplied -->
> </xsl:when>
> <xsl:otherwise> <!--parameter has been supplied --> </xsl:otherwise>
> </xsl:choose>
>
> The reason this works is that when no actual parameter v is supplied, it
> takes its default value, which in this case is an empty string (because
the
> xsl:param has no select expression or content), and the test not($v)
returns
> true if $v is an empty string.

That works SWEET.  Thanks a lot.

Scott


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.