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

Programming without Assignment Statements

Subject: Programming without Assignment Statements
From: Dan.Diebolt@xxxxxxxxxxx
Date: Fri, 5 Jan 2001 08:41:32 -0500
programming without assignment statements
I am reading XSLT Programmer's Reference by Michael Kay and he
has a discussion on the topic "Programming without Assignment Statements"
The following example is offered (p551) to demonstrate the paradigm shift
from procedural programming to functional programming

   int x;
   if (zeroBased) {
      x=0;
   } else {
      x=1;
   }

   <xsl:variable name="x">
      <xsl:choose>
         <xsl:when test="$zeroBased"> 0 </xsl:when>
         <xsl:otherwise> 1 </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>

How would the example above be extended to XSLT using an if statement with more
complex then and else bodies such as below?

   int x,y;
   if (zeroBased) {
      x=0;
      y=3.14159;
   } else {
      x=1;
      y=2.71828;
   }

The following seems verbose, inefficient and impractical:

   <xsl:variable name="x">
      <xsl:choose>
         <xsl:when test="$zeroBased"> 0 </xsl:when>
         <xsl:otherwise> 1 </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>

   <xsl:variable name="y">
      <xsl:choose>
         <xsl:when test="$zeroBased"> 3.14159 </xsl:when>
         <xsl:otherwise> 2.71828 </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>

Please cc a response direct to me as I am on digest. Thanks in advance.


 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.