Skip to Content
0
Jul 12, 2007 at 09:45 AM

Java mapping code for looping through a node. Kindlty help!

19 Views

Hi Experts,

I have source message:

<ProductlineItem>

<ProductIdentification>

<ClassificationCode>Reseller</ClassificationCode>

<ProductIdentifier>MM001</ProductIdentifier>

</ProductIdentification>

<ProductIdentification>

<ClassificationCode>Manufacturer</ClassificationCode>

<ProductIdentifier>MM002</ProductIdentifier>

</ProductIdentification>

<ProductIdentification>

<ClassificationCode>Sender</ClassificationCode>

<ProductIdentifier>MM003</ProductIdentifier>

</ProductIdentification>

</ProductlineItem>

<ProductlineItem>

<ProductIdentification>

<ClassificationCode>Sender</ClassificationCode>

<ProductIdentifier>KK001</ProductIdentifier>

</ProductIdentification>

<ProductIdentification>

<ClassificationCode>Manufacturer</ClassificationCode>

<ProductIdentifier>KK002</ProductIdentifier>

</ProductIdentification>

<ProductIdentification>

<ClassificationCode>Reseller</ClassificationCode>

<ProductIdentifier>KK003</ProductIdentifier>

</ProductIdentification>

</ProductlineItem>

As shown above each product can have multiple indentification. For each product item I have to map the <ProductIdentifier> value to <MM> of target message where <ClassificationCode> is Manufacturer. Similarly map the <ProductIdentifier> value to <CPN> of target message where <ClassificationCode> is Sender.

I want to generate the output(target) message as below:

<ITAB_PRODUCT>

<Item>

<MM>MM002</MM>

<CPN>MM003</CPN>

</Item>

<Item>

<MM>KK002</MM>

<CPN>KK001</CPN>

</Item>

<ITAB_PRODUCT>

How can I get the target message? I beleive I have to use Java user defined function where I have to do some looping. kIndly help me with some sample java code for the same to get the target message.

Kindly help!

Thanks

Gopal