Good day!

We have to push an input XML file (see format below) thru an XSLT to transform it to a regular XML which can be read by our 3rd party software. The problem is, the XSLT will only store 1 set of "Identifier" and its subsequent "Quantity" values. I am only able to grab the first value of the "Identifier" and sum up all the succeeding "Quantity" correctly. And this is not working for us because there could be multiple "Identifier" values with its own set of "Quantity" rows underneath.

How can I add new nodes/elements(?) to replicate the 1st group whenever the value of the "Identifier" changes? Once the new nodes/elements are added, I want to bring over the same values in the first.

Of course, I'm new to the XML/XSLT world and I have no clue how to go about doing this. Would really, really appreciate any help or tips to the right info/resource on the web on how to crack this.

Thank you much!

Raw Input XML File:
<UsageLineItemDetail UsageStatus="Consumed" ItemType="ReelItem">
<Identifier IdentifierCodeType="Supplier" IdentifierType="Primary">26.5~70~INFLUENCE MATTE</Identifier>
<Quantity QuantityType="NetNetWeight" QuantityTypeContext="Consumed">
<Value UOM="Pound">3544</Value>
</Quantity>
</UsageLineItemDetail>
<UsageLineItemDetail UsageStatus="Consumed" ItemType="ReelItem">
<Identifier IdentifierCodeType="Supplier" IdentifierType="Primary">26.5~70~INFLUENCE MATTE</Identifier>
<Quantity QuantityType="NetNetWeight" QuantityTypeContext="Consumed">
<Value UOM="Pound">3550</Value>
</Quantity>
</UsageLineItemDetail>
<UsageLineItemDetail UsageStatus="Consumed" ItemType="ReelItem">
<Identifier IdentifierCodeType="Supplier" IdentifierType="Primary">26.5~70~INFLUENCE MATTE</Identifier>
<Quantity QuantityType="NetNetWeight" QuantityTypeContext="Consumed">
<Value UOM="Pound">3618</Value>
</Quantity>
</UsageLineItemDetail>

Generated XML Section I want to replicate whenever the value in the "Identifier" changes:
<NEW_ID class="R">
<JID>3674572</JID> (copy value to new element as well)
<TID>1</TID> (copy value to new element as well)
<NBR>1</NBR> (copy value to new element as well)
<DUNS>091646489</DUNS> (copy value to new element as well)
<WRAP>348</WRAP> (copy value to new element as well)
<STRIP>185<STRIP> (copy value to new element as well)
<CORE>234</CORE> (copy value to new element as well)
<RUN>3130</RUN> (copy value to new element as well)
<PROD>Product??</PROD> (copy value to new element as well)
<DESC>16.188~70~STERLING ULTRA WEB GLOSS</DESC> (info that changes)
<C10/>
<INV/>
<USG>105816</USG> (sum all instances of "Quantity" underneath)
<NEW_ID>

Recommended Answers

All 2 Replies

Wheter do you want this section to be inserted into?

Wheter do you want this section to be inserted into?

thanks. i've already coded in the solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.