Subject: Re: [xsl] tail recursion optimization (was How efficient is DVC?) From: "David Rosenborg" <darolst@xxxxxxxxxx> Date: Sun, 23 Mar 2003 11:44:44 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] tail recursion optimizati, Mike Brown | Thread | RE: [xsl] tail recursion optimizati, Michael Kay |
Re: [xsl] tail recursion optimizati, Robbert van Dalen | Date | Re: [xsl] Re: How efficient is DVC?, Robbert van Dalen |
Month |