xsl-list
[Top] [All Lists]

Transactions on Inventory

2004-02-29 19:56:53

I have source XML that models a series of transactions on a single item of
inventory (set inventory, add to inventory or subtract from inventory) and
looks like this:

Input:
<root>
 <item>
  <date>1/1/04</date>
  <oper>set   </oper>
  <qnty>100   </qnty>
 </item>
 <item>
  <date>1/2/04</date>
  <oper>add   </oper>
  <qnty>50    </qnty>
 </item>
 <item>
  <date>1/3/04</date>
  <oper>sub   </oper>
  <qnty>100   </qnty>
 </item>
 <item>
  <date>1/4/04</date>
  <oper>set   </oper>
  <qnty>40    </qnty>
 </item>
 <item>
  <date>1/5/04</date>
  <oper>sub   </oper>
  <qnty>10    </qnty>
 </item>
 <item>
  <date>1/6/04</date>
  <oper>add   </oper>
  <qnty>30    </qnty>
 </item>
</root>

The <oper> tag represents the operation performed on the inventory:

set - sets the quantity on the inventory as if an audit was done to establish
determine the explicit amount of inventory on hand
add - receives the quantity of new inventory into stock
sub - disburses the quantity of existing inventory from stock

The desired output is an HTML table with the following column layout:

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.
 
Thanks for any help you can provide. A copy of any response to
dandiebolt(_at_)yahoo(_dot_)com would be appreciated as I am on digest. 


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



<Prev in Thread] Current Thread [Next in Thread>
  • Transactions on Inventory, Dan Diebolt <=