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

Re: XSLT repetition constructs

Subject: Re: XSLT repetition constructs
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 5 Mar 2019 20:01:59 -0000
Re:  XSLT repetition constructs
>  I donbt have enough experience
> with using xs:iterate in larger stylesheets

xsl:iterate has two main applications

(a) when you want to stop processing input elements when some condition
becomes true (e.g. when you hit the first <pageBreak> element)

(b) when you want the result of processing one input element to depend on the
results of processing previous elements; for example, if you want to insert a
page break when the sum of the sizes of previous elements exceeds some

We reported at XML Prague on the XSLT compiler we are writing in XSLT, and
that uses xsl:iterate very extensively. For example, when you're processing
the instructions in a sequence constructor, you want to keep track of which
local variables are in scope, so you want to process instructions sequentially
keeping the set of local variables as current state.

You can always achieve the same effect using recursion. But after years of
practice, I still find recursive templates are a pig to debug.

The reason for introducing xsl:iterate was because (compared with recursive
templates) it makes the streamability analysis feasible. But it ends up being
a very convenient construct quite independent of streaming. In fact, it's easy
to slip into using it all the time, in place of xsl:for-each. If there's no
xsl:break, xsl:param, xsl:next-iteration, xsl:on-completion, or xsl:sort, then
the two constructs are 100% equivalent.

Michael Kay

Current Thread


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.
First Name
Last Name
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.