Subject: [xsl] Programming without Assignment Statements From: Dan.Diebolt@xxxxxxxxxxx Date: Fri, 5 Jan 2001 08:41:32 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to create XSL for CAL, Richard Lander | Thread | Re: [xsl] Programming without Assig, David Carlisle |
Re: [xsl] XSLT or DOM or SAX?, Craig Pfeifer | Date | [xsl] Sample of grouping and sortin, Peter Paulus |
Month |