|
Subject: RE: [xsl] Functional Programming: How do I convert an xsl:for-each loop into a functional style? From: "Costello, Roger L." <costello@xxxxxxxxx> Date: Thu, 21 Jan 2010 11:03:52 -0500 |
Thanks everyone for your responses. They have been very enlightening.
However, I am struggling to characterize what "functional programming" means.
How will I recognize that one XSLT program is written in a functional style
while another is not?
Let's take an example. Suppose I want to execute Statement 1 if Number is
greater than 20, and Statement 2 if Number is greater than 10.
Here's one way to implement this:
<xsl:choose>
<xsl:when test="Number gt 20">
Statement 1
</xsl:when>
<xsl:when test="Number gt 10">
Statement 2
</xsl:when>
</xsl:choose>
Suppose Number has the value 25. If the two xsl:when tests can be executed in
any order, then Statement 2 could be executed, which is not what I desire.
Thus, I conclude, this xsl:choose is not written in a functional style. Do you
agree?
Now, let me recast the implementation:
<xsl:choose>
<xsl:when test="Number gt 20">
Statement 1
</xsl:when>
<xsl:when test="(Number gt 10) and (Number le 20)">
Statement 2
</xsl:when>
</xsl:choose>
Now I get the desired results no matter what order the xsl:when tests are
executed. Thus, I conclude, this xsl:choose is written in a functional style.
Do you agree?
/Roger
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Functional Programming: H, David Carlisle | Thread | Re: [xsl] Functional Programming: H, David Carlisle |
| Re: [xsl] XML/XSLT programmer job a, Vyacheslav Sedov | Date | Re: [xsl] Functional Programming: H, David Carlisle |
| Month |