Merge Two XML Files -> without using document() method of xsl
Hi,
I have 2 xml files as shown below.
First.xml
<Info>
<status>
<key>100</key>
</status>
<content>
<number>123456</number>
<height>23</height>
</content>
</info>
Second.xml
<Info>
<status>
<key>101</key>
</status>
<content>
<number>123456</number>
<weight>73</weight>
</content>
</info>
after merging the above 2 files the o/p shud look like,
Otput.xml
<Info>
<status>
<key>900</key>
</status>
<content>
<number>123456</number>
<height>23</height>
<weight>73</weight>
</content>
</info>
The value for the 'key' element of the o/p xml is generated from a mapping based on the values of the key element of the first and second xml.
The two input xml's are sent into the appl asxml strings. I cannot use document function of xsl as it depends on a external document and what i have got here is 2 xml strings.
I can use DOM, build a document, get the required elements by tag name, append and create the required o/p.But this is kept as a fallback approach.
My question is whether i can merge 2 xml strings using XSLT. If yes, could anyone post few samples.
Any help would be greatly appreciated.
[1588 byte] By [
sat_83a] at [2007-11-27 9:49:38]

# 1
> The value for the 'key' element of the o/p xml is
> generated from a mapping based on the values of the
> key element of the first and second xml.
Can the value of 'key' be computed on the fly, using other 2 'key' values ?
> The two input xml's are sent into the appl as xml
> strings. I cannot use document function of xsl as
> it depends on a external document and what i have got
> here is 2 xml strings.
> I can use DOM, build a document, get the required
> elements by tag name, append and create the required
> o/p.But this is kept as a fallback approach.
If you want to make changes in one of the source XML files directly then DOM is the only approach, since, with XSL you get a third file as output.
> My question is whether i can merge 2 xml strings using XSLT.
Yes, but it depends on how the new 'key' value is deduced ?
> If yes, could anyone post few samples.
?
# 2
Thanks java_ for the input!!!
> Can the value of 'key' be computed on the fly, using
> other 2 'key' values ?
yes.
>
> If you want to make changes in one of the source XML
> files directly then DOM is the only approach, since,
> with XSL you get a third file as output.
I don't mind getting a third file as output. The bottom line is i just have to merge 2 xml strings using XSLT.
> Yes, but it depends on how the new 'key' value is
> deduced ?
The key value can be deduced as you have mentioned above 'on the fly'.
> ?
I meant i just need some inputs on how to proceed in the right direction.