3

I want to get multiple output from a single XML input message.

<List>
<type>mailbox</type>
<Docs>
  <DocID>38ghjk</DocID>
</Docs>
<Docs>
  <DocID>39ghjk</DocID>
</Docs>

This is how my XML looks it contains more DocID. My requirement is I want separate output messages for each DocID. I tried with while loop but I'm not getting separate messages for each DocIDs. I can fetch all DocIDs but I'm not able to get Separate Output each DocID.

Please suggest any way or solution to do it and please comment for any queries.

JoshMc
  • 10,239
  • 2
  • 19
  • 38
Amrit
  • 137
  • 2
  • 2
  • 13

2 Answers2

3
DECLARE I INTEGER;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.XMLNSC.List.Docs[]);
SET I = 1;
WHILE I < J  DO
SET OutputRoot.XMLNSC.LIST.DocId[K] = InputRoot.XMLNSC.List.Docs[I].DocId;
PROPAGATE TO TERMINAL 'out' delete none;
SET I = I + 1;
END WHILE;

Earlier I was not using propagate statement so I was getting single output but now I'm getting different output for all docid.

Amrit
  • 137
  • 2
  • 2
  • 13
2

CARDINALITY is not the Best way to do that, you can do something like:

DECLARE refInDocument REFERENCE TO InputRoot.XMLNSC.List.Docs;
WHILE LASTMOVE(refInDocument) DO
   SET OutputRoot.XMLNSC.Docs.DocId = refInDocument.DocId;
   PROPAGATE TO TERMINAL 'out' delete none;
   MOVE refInDocument NEXTSIBLING;
END WHILE;

You can read more about that at IBM documentation in this link: https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/bj28653_.htm