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

RE: implement for loop with XSLT

Subject: RE: implement for loop with XSLT
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Sun, 18 Mar 2001 22:08:07 -0000
paging xslt loop
> I came up with the enclosed code to grab the value of an <n> element
> and generate a list of integers and their squares between 1 and n:
>
>    1 1
>    2 4
>    3 9
>    ...
>    8 64
>    9 81
>    10 100
>
> I am a bit stunned at how intricate this code looks. Is there
> a more direct way to accomplish this?

No, the way you have done it is the correct way. It's rather verbose, but
it's conceptually simple, and by writing it you have learnt a powerful and
extensible technique.

> If I am stuck with this recursive solution, is there a way
> to write a generic "for" template but pass in a "body" that
> needs to be evalutate? For example pass a string "$i*$i*$i"
> to evaluate cubes).

You're really asking here for first-class functions or lambda expressions,
something that is the subject of some of the heavy theoretical discussion on
this list that you're probably ignoring and dismissing as irrelevant.

Meanwhile you could play with the evaluate() extension function available in
Saxon, Xalan, etc.

Mike Kay
Software AG


 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.