xsl stylesheet to sum values based on multiple grouping - muenchian (1.0)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I want to obtain a better xml file using some xslt and xml below.
<?xml version="1.0" encoding="UTF-8"?>
<span style="white-space:pre <Pallets><Pallet>
<span style="white-space:pre <PalletNumber>2</PalletNumber><br/>
<span style="white-space:pre <Product>1</Product><br/>
<span style="white-space:pre <Quantity>2</Quantity><br/>
<span style="white-space:pre </Pallet><br/>
<span style="white-space:pre <Pallet><br/>
<span style="white-space:pre <PalletNumber>2</PalletNumber><br/>
<span style="white-space:pre <Product>1</Product><br/>
<span style="white-space:pre <Quantity>4</Quantity><br/>
<span style="white-space:pre </Pallet><br/>
<span style="white-space:pre <Pallet><br/>
<span style="white-space:pre <PalletNumber>2</PalletNumber><br/>
<span style="white-space:pre <Product>2</Product><br/>
<span style="white-space:pre <Quantity>1</Quantity><br/>
<span style="white-space:pre </Pallet><br/>
<span style="white-space:pre <Pallet><br/>
<span style="white-space:pre <PalletNumber>3</PalletNumber><br/>
<span style="white-space:pre <Product>1</Product><br/>
<span style="white-space:pre <Quantity>2</Quantity><br/>
<span style="white-space:pre </Pallet><br/>
<span style="white-space:pre <Pallet><br/>
<span style="white-space:pre <PalletNumber>4</PalletNumber><br/>
<span style="white-space:pre <Product>2</Product><br/>
<span style="white-space:pre <Quantity>2</Quantity><br/>
<span style="white-space:pre </Pallet></Pallets>
<span style="white-space:pre I need to sum up quantity per pallet number and product(see first node below) .Also sequence number is needed in the right part of palletnumber value based on first appearance in the xml.Results should look like
:
<span style="white-space:pre <Pallets><Pallet><br/>
<span style="white-space:pre <PalletNumber>2_1</PalletNumber><br/>
<span style="white-space:pre <Product>1</Product><br/>
<span style="white-space:pre <Quantity>6</Quantity><br/>
<span style="white-space:pre </Pallet><br/>
<span style="white-space:pre <Pallet><br/>
<span style="white-space:pre <PalletNumber>2_2</PalletNumber><br/>
<span style="white-space:pre <Product>2</Product><br/>
<span style="white-space:pre <Quantity>1</Quantity><br/>
<span style="white-space:pre </Pallet><br/>
<span style="white-space:pre <Pallet><br/>
<span style="white-space:pre <PalletNumber>3_1</PalletNumber><br/>
<span style="white-space:pre <Product>1</Product><br/>
<span style="white-space:pre <Quantity>2</Quantity><br/>
<span style="white-space:pre </Pallet><br/>
<span style="white-space:pre <Pallet><br/>
<span style="white-space:pre <PalletNumber>4_1</PalletNumber><br/>
<span style="white-space:pre <Product>2</Product><br/>
<span style="white-space:pre <Quantity>2</Quantity><br/>
<span style="white-space:pre </Pallet></Pallets>
<span style="white-space:pre Please provide XSLT 1.0 support .Thanks a lot.

View the full article
 
Back
Top