concatenating multiple repeated elements with XSLT

trusySmummisa

New Member
I have below sample xml data. The scenario is that productNo element has to be concatenated with type element value and number element value when the type=#. the concatenated output has to be concatenated with each serialNumber element in that orderItem record. the final requirement is:1. when type element is '#' then productNo concatenation with each type element and number elements should be concatenated with each serialNumber element in each orderItem record.2. when type element doesn't have '#' then productNo should be concatenated with each serialNumber element in each orderItem record\[code\] <orderItems> <orderItem itemNo="0100" sapItemNo="10"> <productNo>WK302EA</productNo> <itemShipDetails> <itemShipDetail> <serialNumber>CZC132BM61</serialNumber> </itemShipDetail> <itemShipDetail> <serialNumber>CZC1331JR2</serialNumber> </itemShipDetail> <itemShipDetail> <serialNumber>CZC1331JR3</serialNumber> </itemShipDetail> </itemShipDetails> <options> <option ln="01" type="" sapItemNo="10"> <number>WK302EA</number> </option> <option ln="02" type="#" sapItemNo="10"> <number>ABN</number> </option> <option ln="03" type="#" sapItemNo="10"> <number>ASZ</number> </option> </options> </orderItem> <orderItem itemNo="0200" sapItemNo="20"> <productNo>VY623AA</productNo> <itemShipDetails> <itemShipDetail> <serialNumber>CN3129300D</serialNumber> </itemShipDetail> <itemShipDetail> <serialNumber>CN3129300Z</serialNumber> </itemShipDetail> <itemShipDetail> <serialNumber>CN3129306S</serialNumber> </itemShipDetail> <itemShipDetail> <serialNumber>CN312930LM</serialNumber> </itemShipDetail> </itemShipDetails> <options> <option ln="04" type="" sapItemNo="20"> <number>VY623AA</number> </option> <option ln="05" type="#" sapItemNo="20"> <number>ABN</number> </option> </options> </orderItem> <orderItem itemNo="0300" sapItemNo="30"> <productNo>VY623AS</productNo> <itemShipDetails> <itemShipDetail> <serialNumber>CN3129300X</serialNumber> </itemShipDetail> <itemShipDetail> <serialNumber>CN3129300P</serialNumber> </itemShipDetail> </itemShipDetails> <options> <option ln="06" type="" sapItemNo="30"> <number>VY623AS</number> </option> <option ln="07" type="M" sapItemNo="30"> <number>ABC</number> </option> </options> </orderItem> </orderItems>\[/code\]The expected Output is:\[code\] <orders> <serialNO>WK302EA#ABN|CZC132BM61</serialNO> <serialNO>WK302EA#ABN|CZC1331JR2</serialNO> <serialNO>WK302EA#ABN|CZC1331JR3</serialNO> <serialNO>WK302EA#ASZ|CZC132BM61</serialNO> <serialNO>WK302EA#ASZ|CZC1331JR2</serialNO> <serialNO>WK302EA#ASZ|CZC1331JR3</serialNO> <serialNO>VY623AA#ABN|CN3129300D</serialNO> <serialNO>VY623AA#ABN|CN3129300Z</serialNO> <serialNO>VY623AA#ABN|CN3129306S</serialNO> <serialNO>VY623AA#ABN|CN312930LM</serialNO> <serialNO>VY623AS|CN3129300X</serialNO> <serialNO>VY623AS|CN3129300P</serialNO> </orders>\[/code\]
 
Back
Top