Re: [xslt] How to implement unusual chunking in a stylesheet



John Hurst writes:
> G'day Peter,
> 
> On Sun, 09 Jun 2002 00:27:24 -0400, Peter Williams wrote:
> > Hi John,
> > 
> > On Sat, 2002-06-08 at 21:43, John Hurst wrote:
> > > G'day Peter,
> > > 
> > > Something like?
> > > 
> > > <xsl:template match="item">
> > >    <xsl:for-each select="node">
> > >      <item><node><xsl:apply-templates select="."/></node></item>
> > >    </xsl:for-each>
> > > </xsl:template>
> > > 
> > 
> > Uh, how does this achieve chunking? I want to create multiple output
> > documents, like the Docbook's chunk.xsl, where each document contains
> > no more than, say, 20 <node>s, and however many <item>s are necessary
> > to contain them.
> 
> Sorry, I guess I misunderstood your original question.
> 
> This would go beyond my immediate skills in XSLT, but I'd attempt it by
> building some sort of temporary result tree in a local variable (using
> something like the above loop to fill the result tree), and outputting
> that when it got to the required size.
> 
You cannot do that this way in XSLT.
XSLT variables are more like constants. So in a normal loop you cannot
collect data in a variable.

So you have to redo the loop with recursive function calls.
There is an article on how to do things like that on www.xml.com
(look for looping).
It's not nice but it's doable.

BTW: a general xslt mailing list would be more appropriate than
the libxslt list.

greetings
	Morus



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]