|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








