[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] "Tunneling" a parameter in document order


Subject: Re: [xsl] "Tunneling" a parameter in document order
From: Christian Roth <roth@xxxxxxxxxxxxxx>
Date: Sat, 14 Apr 2012 13:09:07 +0200

On 13.04.2012, at 11:02, David Carlisle wrote:

> do
>
>
> <xsl:template match="*">
>   ... <xsl:apply-templates
select="(*,ancestor-or-self::*[following-sibling::*][1]/following-sibling::*)
[1]/>
> </xsl:template>
>
> as that will match elements in the order
> a,b1,c1,b2,c2,b3,c3
> so you can pass information using parameters down that order.

Thanks David, this technique looks great and seems what I was looking for. It
took me a little while to understand how and why the select="..." works,
however :-)

Am I correct that by using the above, the maximum nesting depth of template
calls is the number of (here:) elements in the source document? I tried with
Saxon HE and got a "Too many nested apply-templates calls. The stylesheet may
be looping." error after already 636 elements. I have to deal with documents
eventually that have >100k elements.

I'll have to look into ways of avoiding that error, like reducing the
candidate elements and "skipping" the ones for which I know that they will not
change the tunnel variable's value so that I do not recurse into a template
for them. On the other hand, I am sure that reasonable documents will have
more than around 600 list items in them, so that alone won't suffice.

Again, thanks for the great idea, and I now just need to work out the
details...

-Christian


Current Thread