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

RE: Functional Programming: How do I convert an xsl:f

Subject: RE: 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
RE:  Functional Programming: How do I convert an  xsl:f
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

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.