xsl-list
[Top] [All Lists]

Increment value by group

2006-01-11 09:18:10
Hello:  I want to process nodes based on grouping by <quantity>. The  
<increment> element is used as a running "total" based on grouping.  So 
basically, when <quantity> is "1", I want to process all of them as a group and 
use the <increment> value to produce an output like this:

1/1-3 (i.e. <increment> value is "3")
1/4-5 (i.e. <increment> value if "2" but starts with preceding <increment value)

When <quantity> changes, I want the <increment> value to also start over with 
"1".

Can I use <xsl:for-each-group> or some such element to accomplish this.

<?xml version="1.0"?>
<document>
<job>
<quantity>1</quantity>
<increment>3</increment>
</job>
<job>
<quantity>1</quantity>
<increment>2</increment>
</job>
<job>
<quantity>2</quantity>
<increment>4</increment>
</job>
<job>
<quantity>2</quantity>
<increment>1</increment>
</job>
</document>

Desired output:

<document>
<job>
<status>1/1-3</status>
</job>
<job>
<status>1/4-5</status>
</job>
<job>
<status>1/6</status>
</job>
<job>
<status>2/1-4</status>
</job>
<job>
<status>2/5</status>
</job>
</document>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>