[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: tail recursion optimization (was How efficient is
Mike Brown wrote: > <xsl:template match="group"> > <xsl:copy> > <xsl:copy-of select="@*"/> > <xsl:copy-of select="./city"/> > </xsl:copy> > <xsl:apply-templates select="./group"/> > </xsl:template> > > I don't know if any processors can optimize this. It may seem obvious to you > and me that the apply-templates instruction will result in this same template > being applied, but there might be some other template that also matches > certain 'group' elements at a higher priority, so there's no easy way for the > processor to be sure (before runtime) that this template will be the one that > is invoked for every one of the selected nodes. Or at least, the analysis > required to be certain that this is tail-recursive is not simple enough that > anyone has bothered to figure it out yet. (Suggestions welcome...) > >From a tail call perspecitve, there is no real difference between a named template call and applying templates. Tail call opt. has more to do with where the call appears than how and what is being called. The key issue is to leave or reuse the current stack frame before you make the call. The only difference in an apply-templates call is that it actually issues one call per selected node, so you would need to reuse the stack frame for each of these calls. The fact that the actual template applied is decided dynamically is not a tail call issue. Cheers, David ----------------------------------------------- David Rosenborg Pantor Engineering AB XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|