RE: [xsl] Transactions on Inventory

Subject: RE: [xsl] Transactions on Inventory
From: Jarno.Elovirta@xxxxxxxxx
Date: Mon, 1 Mar 2004 08:57:40 +0200
Hi,

> Desired Output:
> 
> date oper qty cumulative
> 1/1/04 set 100 100
> 1/2/04 add 50 150
> 1/3/04 sub 100 50
> 1/4/04 set 40 40
> 1/5/04 sub 10 30
> 1/6/04 add 30 30
> 
> The <item>'s may or may not be ordered by increasing date.
> 
> Does anyone have an idea what the best approach to tackling 
> this problem is?
> This is a grouping problem but I am not doing just one 
> operation like a running
> sum. The number that shows up in the cumulative column could 
> be the results of
> setting, adding or subtracting from prior inventory level.
> 
> I would prefer a solution that did not use extension 
> functions or libraries as
> this statement of the problem is a implification of the 
> larger problem that I
> am tackling (multiple inventory items, categories of 
> inventory etc). The XSLT
> has to work in IE6.

Just IE6? The easiest in that case would be to first make a copy of the input tree with items ordered by date (see the FAQ for ordering by various date formats), cast the RTF into a node-set by using the extension function provided by MSXML, then write recursive template that starts from the first and goes throught the list, outputting the table rows and calculating the cumulative quantity. If you absolutely don't want to use extensions, either go with the two pass solution of first sorting, then processing; there are one pass, pure XSLT 1.0 solutions, but using the node-set extension makes your life easier.

Cheers,

Jarno

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread