[xsl] Merge based on shared element value

Subject: [xsl] Merge based on shared element value
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Apr 2015 14:43:25 -0000
Hi Srinivas,

I have started a new thread with a new subject line. In future, please
don't "Reply To" with new messages as it prevents messages from being
sorted usefully in the archives.

In response to your question - why do (you think) you want a solution
"based on Operation Using Nested For loop with IF Condition"?

To solve the problem you have presented is straightforward, even
trivial, with xsl:for-each-group (in XSLT 2.0). You only need to
collect all your Source1 elements (from both documents) in a sequence,
then group them by the values of 'Operation'.

Then perhaps you need a policy for detecting and avoiding unwanted
"duplication" of Source2 elements in your groups - a part of the
problem you have not presented. (This could be done by grouping inside
the group.)

Cheers, Wendell

=================

Your message:

Hi all,

I have a requirement as below.

i have one source xml, which as below.

<Source>
    <Source1>
           <Operation>XXXXXX</Operation>
           <Source2>
                 <Name>XXXX</Name>
                 <Address>XXXX</Address>
            </Source2>
            <Source2>
                 <Name>XXXX</Name>
                 <Address>XXXX</Address>
            </Source2>
     </Source1>
</Source>.

I have one Config XML, which as below.

<Source>
    <Source1>
          <Operation>XXXXXX</Operation>
           <Source3>
                 <City>XXXX</City>
                 <State>XXXX</State>
            </Source3>
     </Source1>
</Source>.

I want to merge the second xml with my source xml based on the
Operation Name, my desired output xml should be.

<Source>
    <Source1>
           <Operation>XXXXXX</Operation>
           <Source2>
                 <Name>XXXX</Name>
                 <Address>XXXX</Address>
            </Source2>
           <Source3>
                 <City>XXXX</City>
                 <State>XXXX</State>
            </Source3>
    </Source1>
</Source>.

like wise i have couple of config xml's, i need to merge them into
source file based on Operation Using Nested For loop with IF
Condition.

I am new to XSLT, please help me to understand this.

Thanks for advance.

[signed]

-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^

Current Thread