xsl-list
[Top] [All Lists]

Re: [xsl] Group elements based on summing values (XSL 1.0)

2015-02-06 05:24:25
Well if you need to group things in XSLT 1.0 the stock answer here tends to
be Muenchian grouping.

 Some people have internalized the algorithm but I am not one of them as I
rarely ever used it so in that sense i'm as rusty as you are. But thats
your pointer.

On Fri, Feb 6, 2015 at 10:44 AM, Kevin Bird kevinbrianbird(_at_)gmail(_dot_)com 
<
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hello,

My XSL skills are a bit rusty.

Starting from the first <num> element, I need to create the smallest group
possible where the sum of the <num> elements totals 10 or more. I am only
able to use XSL 1.0.

INPUT:
<row>
    <num>3</num>
    <num>4</num>
    <num>4</num>
    <num>7</num>
    <num>12</num>
    <num>15</num>
    <num>1</num>
</row>

OUTPUT:
<row>
    <group1>
        <num>3</num>
        <num>4</num>
        <num>4</num>
    </group1>
    <group2>
        <num>7</num>
        <num>12</num>
        <num>15</num>
        <num>1</num>
    </group2>
</row>

Any help/pointers appreciated.

--
Kevin



--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>