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

Re: Adding Variables

Subject: Re: Adding Variables
From: Deirdre Saoirse Moen <deirdre@xxxxxxxxxxx>
Date: Mon, 16 Aug 2004 00:56:07 -0700
xslt adding variables
I realize this is an old thread, but there was something I'd looked up when this thread was new and wasn't certain about.

On Jun 28, 2004, at 4:43 AM, Michael Kay wrote:

<xsl:variable name="num1" select="//test1/somevalue1"/>

(The compiler can't automatically convert one to the other, because some
expressions treat them differently, for example boolean($num1) is always
true in the first case, but in the second case it is true only if
//test1/somevalue1 selects at least one node).

What I've never quite understood is how to wrap this into a conditional.


Based on http://www.dpawson.co.uk/xsl/sect2/N8090.html#d9711e895 example, would this be correct for wrapping an assignment in only if a variable was passed in, otherwise using the default?

<xsl:variable name="n">
<!--Conditionally instantiate a value to be assigned to the variable -->
<xsl:choose>
<xsl:when test=="//test1/somevalue1">
<xsl:variable name="num1" select="//test1/somevalue1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="20"/><!-- ...or a "20" -->
</xsl:otherwise>
</xsl:choose>
</xsl:variable>


--
_Deirdre http://deirdre.net
"Cannot run out of time. There is infinite time. You are finite. Zathras is finite. This....is wrong tool." -- Zathras


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-2011 All Rights Reserved.