Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

muenchian sum based on multiple grouping

Status
Not open for further replies.

chopstix21

Technical User
May 23, 2012
2
RO
I want to obtain a better xml file using some xslt and xml below.

<?xml version="1.0" encoding="UTF-8"?>

<Pallets><Pallet>

<PalletNumber>2</PalletNumber>
<Product>1</Product>
<Quantity>2</Quantity>
</Pallet>
<Pallet>
<PalletNumber>2</PalletNumber>
<Product>1</Product>
<Quantity>4</Quantity>
</Pallet>
<Pallet>
<PalletNumber>2</PalletNumber>
<Product>2</Product>
<Quantity>1</Quantity>
</Pallet>
<Pallet>
<PalletNumber>3</PalletNumber>
<Product>1</Product>
<Quantity>2</Quantity>
</Pallet>
<Pallet>
<PalletNumber>4</PalletNumber>
<Product>2</Product>
<Quantity>2</Quantity>
</Pallet></Pallets>

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 :

<?xml version="1.0" encoding="UTF-8"?>

<Pallets><Pallet>
<PalletNumber>2_1</PalletNumber>
<Product>1</Product>
<Quantity>6</Quantity>
</Pallet>
<Pallet>
<PalletNumber>2_2</PalletNumber>
<Product>2</Product>
<Quantity>1</Quantity>
</Pallet>
<Pallet>
<PalletNumber>3_1</PalletNumber>
<Product>1</Product>
<Quantity>2</Quantity>
</Pallet>
<Pallet>
<PalletNumber>4_1</PalletNumber>
<Product>2</Product>
<Quantity>2</Quantity>
</Pallet></Pallets>

Please provide XSLT 1.0 support .Thanks a lot.
 
See faq426-6585 for a start. You might also pick up a hint from this thread: thread426-1547313

Then provide your XSLT, and ask technical questions.

Tom Morrison
Micro Focus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top