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

Re: declarative language, need for loops etc.

Subject: Re: declarative language, need for loops etc.
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 16 Oct 2002 10:37:24 -0600 (MDT)
xslt declarative language
thomas wrote:
> In my experience as an beginner in xslt I understand slowly whats 
> "behind" xslt as a declarative language. What I dont understand is, that 
> there is still some "need" for iterative solutions wich is not part in 
> the xslt.
> And I have to do something like this:
> http://www.informatik.hu-berlin.de/~obecker/XSLT/loop-compiler/
> 
> Wich basic concepts is missing? What do I not understand?

Accumulators (variables that change, for computing totals/subtotals) can be
simulated with recursive function calls, thus eliminating the need for each
iteration to preserve its state or to modify the state of something on the
side ("having side effects"); or they can be circumvented entirely by
redefining how totals are calculated. Very often, the info one needs to 
compute the subtotal is available to other functions like sum(), with a 
creative XPath expression to select the right input nodes.

Iterating a fixed number of times is often a solution to generating
paginated/grouped output (n iterations per page, for example), and this is
easily solved by defining output in terms of a page for every (n)th item,
where a page contains that item and the next (n-1) items. For more complex
grouping problems, there are less natural but very effective ways of solving
them, as explained at www.jenitennison.com, in Michael Kay's XSLT Reference
book (among others), and in the FAQ at www.dpawson.co.uk.

Of course, there are still times when you might really need a fixed number of
iterations where the number has nothing to do with the input XML, in which
case there is the recursive template solution, also in the FAQ.

If you have reviewed those resources and still have a specific problem where
you think you need a procedural solution, post it here (reducing it to a
simple test case if possible), with your input XML and desired output. One of
the many helpful people on the list will almost certainly tell you what the
declarative, functional way of doing it is.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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.