[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Splitting data into smaller groups for HTML output

Subject: Re: Splitting data into smaller groups for HTML output.
From: Mike Rumble <mike.rumble@xxxxxxxxx>
Date: Mon, 31 Oct 2005 19:03:14 +0000
splitting data with xquery
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() &lt;= (last() div 2)"/>
>    </div>
>    <div>
>      <xsl:apply-templates
>        select="source[position() &gt; (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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.