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?
An example might help here:
I hvae two forms which share the same "master schema" that contains the superset of the elements of the two forms.
So I have this:
So for example I have an xml variable where one person has filled out all fields for form1 and now I want to put in these into another xml variable where another person (in parallel) has filled out all info in form2. How can this be done without making a assignment to each element one at a time.
E.g. I don't wnat to do the following:
myXml1/form1/Name = myXml2/form1/Name
myXml1/form1/Address = myXml2/form1/Address
Can I do this in just one step?
You would have to group you elements.
For example you could have
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.
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.
Thanks for the input - I got it to work by using your suggestion Jasmin.
To Parth: I am not aware how I can use XQuery with LC, can you send a link to where I could find more on this. Also I would like to know more on the XSLT transformations on xml files (I have not yet used them actively in my solutions).
If anyone has info (links or anything) on these issues I would like to hear about it :)
Thanks in advance
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.
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/form1/CompetencyDetails [*]</b><br /><br />to work. Any help will be highly appreciated.
If you want to merge and have the following result
Then you could probably do something like
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.
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.
Jasmin - How is it possible to merge xml structures with repeating elements?
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.