Re: Splitting data into smaller groups for HTML output
Thanks Wendell, The way I'm looking to split the items into groups is as follows. 1 to 5 items - 1 group 6 to 10 items - 2 groups 11 to 15 items - 3 groups 16 - 20 items - 4 groups 21 - 25 items - 5 groups So the number of groups will in fact depend on the number of <source> nodes in the XML file. The <source> nodes will are already in the correct order in the XML file so I don't need to sort them in any other way in the XSL. Cheers, Mike. On 10/31/05, Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote: > Mike, > > The one thing you don't say is by what rule you would like the > splitting to occur (you only say "into two or more groups"). > > If you wanted to split into exactly two groups, you could do: > > <xsl:template match="sources"> > <div> > <xsl:apply-templates > select="source[position() <= (last() div 2)"/> > </div> > <div> > <xsl:apply-templates > select="source[position() > (last() div 2)"/> > </div> > </xsl:template> > > Notice if you have an odd number of source element children, the > first group will be short one item. > > There are other methods available for grouping them differently and > even according to data-driven criteria, for example if you need to > determine dynamically how many groups you want.
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