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

RE: Complex recursion in XSLT 1.0

Subject: RE: Complex recursion in XSLT 1.0
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 18 Feb 2008 13:36:26 -0000
RE:  Complex recursion in XSLT 1.0
> Could you elucidate a little on the concept of a 'stack'. I 
> can only dream of such a thing. What mechanism would you use? 
> and... does that not sound like we need to have a list of all 
> entries first - is that another infinite loop?

OK. You're processing A, and it contains

<topic ref="X"/>
<topic ref="Y"/>

then when you make the call to process X, you pass it a $stack containing
<topic ref="Y"/>.

In X you find

<topic ref="P"/>
<topic ref="Q"/>

so you make a recursive call to process P, passing it a $stack containing
the previous $stack plus <topic ref="Q"/>

When you've finished processing P, you select the last thing on the stack
(which is Q), you process that, passing a stack from which Q has been
removed. Then when you finish processing Q, you select the last thing on the
stack (which is Y) and process that, passing a stack which is now empty.
When you finish processing Y you are done.
> 
> All these Catch 22's are piling up and I'm starting to think 
> that this is fundamentally impossible in XSLT 1.0 because we 
> are not party to essential information about what went 
> before. 

It's absolutely not fundamentally impossible because XSLT is
Turing-complete. I agree it might be a bit mind-bending when you're not used
to this style of coding.

One reason I published the knight's tour stylesheet in my XSLT Programmer's
Reference was to convince people that problems like this could be solved.

Michael Kay
http://www.saxonica.com/

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-2011 All Rights Reserved.