Skip navigation
Currently Being Moderated

Merging to xml variables with identical structure

Jan 7, 2009 12:41 AM

Hi all,

I have two xml variables with identical structure, and I need to merge these two. How can I do this?

Thanks in advance

Sincerely
Kim
 
Replies
  • Currently Being Moderated
    Jan 7, 2009 5:00 AM   in reply to kc@dafolo.dk
    What do you mean by merging the two xml?

    Copy the different elements of each node into the same node structure in the other xml?

    You would have to use the Script service or a custom component to do that?

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 7, 2009 12:02 PM   in reply to kc@dafolo.dk
    You would have to group you elements.

    For example you could have

    form1
    Section1
    Name
    Address
    /Section1
    /form1

    form1
    Section2
    Amount
    CreditCard
    /Section2
    /form1

    That way you can do myXML1/form1/Section1 = myXML2/form1/Section1

    Otherwise you need to do it one by one or use a custom component.

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 7, 2009 3:00 PM   in reply to kc@dafolo.dk
    Hi Kim,
    Do you know xslt or xquery?
    I think doing the xml transformation via xslt or xquery would be an easier alternate for you compared to custom component or script.

    Parth
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 11, 2009 3:01 PM   in reply to kc@dafolo.dk
    Hi Kim,
    To use XQuery with LC, you should install XQuery component as regular dsc and put it's operation as a step in your orchestration.
    Example of it can be found at http://manly.avoka.com.au/confluence/display/Public/Transforming+XML+ Documents
    Have a look at www.w3schools.com for the xslt and xquery tutorials. XSLT and XQuery are really handy to know when you have to work with xml frequently.
    Cheers,
    Parth
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 30, 2009 9:14 AM   in reply to kc@dafolo.dk
    I have a similar issue. The only difference is I have repeating subforms.<br /><br />XML1 contains non repeating subforms. XML2 contains repeating subforms.<br /><br />I would like to add XML2<br /><br /><form1><br />  <CompetencyDetails> <br />       <employee_firstname>Joe</employee_firstname> <br />       <employee_lastname/> <br />    </CompetencyDetails> <br />    <CompetencyDetails> <br />       <employee_firstname>Bob</employee_firstname> <br />       <employee_lastname/> <br />    </CompetencyDetails><br />    </Details><br /></form1> <br /><br />to XML1<br /><br /><form1><br />      </CompetencyDetails><br />      <Details> <br />       <review_from>01122009</review_from> <br />       <review_to>12122009</review_to> <br />       <evaluator_firstname>Sam</evaluator_firstname> <br />       <evaluator_lastname>Evaluator</evaluator_lastname> <br />    </Details><br /><form1><br /><br />Using SetValue I could not get <br /><br /><b>/process_data/xml/form1/CompetencyDetails=/process_data/xml2/for m1/CompetencyDetails[*]</b><br /><br />to work. Any help will be highly appreciated.
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 30, 2009 12:27 PM   in reply to kc@dafolo.dk
    If you want to merge and have the following result


     
           Joe
          
     

     
           Bob
          
     

     

           01122009
           12122009
           Sam
           Evaluator
      



    Then you could probably do something like

    /process_data/xml2/form1/Details=/process_data/xml1/form1/Details/*

    You want to avoid copying the content from the xml that has repeating nodes. In my example I keep the xml with the two repeating nodes (CompetencyDetails) intact and just copy the content of Details over.

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 1, 2009 8:08 AM   in reply to kc@dafolo.dk
    Ha!! I never thought of that. Thank you Jasmin !!

    You saved me a lot of code as I was planning to implement in a custom script.

    Aditya
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2011 10:41 AM   in reply to Aditya S.

    Jasmin - How is it possible to merge xml structures with repeating elements?

     

    Aditya

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 25, 2011 7:48 AM   in reply to Aditya S.

    If you want to use the SetValue service, then you need to make sure to have a parent node for all the repeating nodes and copy that parent node over.

     

    Remember, you can't really copy multiple nodes at the same level.

     

    The other thing you can do it to use the Script service and use DOM manipulation to create your structure.

     

    Jasmin

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)