[xsl] xml to xml mapping - how to combine two groups

Subject: [xsl] xml to xml mapping - how to combine two groups
From: <Andy.Lewis@xxxxxxxxxxx>
Date: Tue, 8 Jan 2008 10:12:50 -0500
I'm not sure how to add to a thread so I'm listing my original question
to be sure. I've added a note at the bottom.

I'm receiving XML data with two different groups of elements. Let's call
them GROUP-A and GROUP-B.

I need to merge the two into single groups of elements. I may have more
of one group than the other.

For example:  I may receive 3 occurrences of GROUP-A and 2 occurrence of
GROUP-B. I want my resulting XML to have 3 occurrences of a new group.
The first two occurrences would contain the elements from both GROUP-A
and GROUP-B. The third occurrence would only contain the elements from
GROUP-A because GROUP-A had one more occurrence than GROUP-B.

Example 2:    2 occurrences of GROUP-A and 6 occurrences of GROUP-B. My
resulting xml should have 6 occurrences of a new group. The first two
would contain elements from both GROUP-A and GROUP-B. The remaining 4
occurrences would contain the elements from the last 4 occurrences of
GROUP-B.

Below is an example of some date.

<LIST_GROUP_A>
<GROUP_A>
<COLOR>red</COLOR>
</GROUP_A>
</LIST_GROUP_A>
<LIST_GROUP_B>
<GROUP_B>
<SHAPE>round</SHAPE>
</GROUP_B>
<GROUP_B>
<SHAPE>square</SHAPE>
</GROUP_B>
</LIST_GROUP_B>

I need to map these into one grouping.
I would like the result to be something like:

<LIST_COMBINED>
<COMBINED>
<COLOR>red</COLOR>
<SHAPE>round</SHAPE>
</COMBINED>
<COMBINED>
<SHAPE>square</SHAPE>
</COMBINED>
</LIST_COMBINED>

The result needs to have two occurrences of COMBINED. The first contains
the first occurrences of GROUP_A and GROUP_B. The second contains the
second occurrence of GROUP_B.

I sure do hope I've explained this.

Thanks! Andy


This message may contain confidential and/or privileged information. This
information is intended to be read only by the individual or entity to whom it
is addressed. If you are not the intended recipient, you are on notice that
any review, disclosure, copying, distribution or use of the contents of this
message is strictly prohibited. If  you have received this message in error,
please notify the sender immediately and delete or destroy any copy of this
message.

Current Thread