xsl-list
[Top] [All Lists]

Re: Merging two xml files

2003-08-26 06:50:37
I am trying to merge two xml files, using a xsl stylesheet...
Basically, the only thing I know about the files is that they have the same
root node.

For example, with the 2 following files:
File1.xml:
<root>
      <elt1 att1="a" att2="b">
              <subelt1 att1="b"/>
              <subelt1 att1="c"/>
      </elt1>
      <elt2 att1="d"/>
</root>

File2.xml:
<root>
      <elt1 att1="a" att2="b">
              <subelt1 att1="c"/>
              <subelt1 att1="d"/>
      </elt1>
      <elt1 att1="a" att2="d">
              <subelt1 att1="x"/>
      </elt1>
      <elt3 att1="e"/>
</root>

Should give something like:
<root>
      <elt1 att1="a" att2="b">
              <subelt1 att1="b"/>
              <subelt1 att1="c"/>
              <subelt1 att1="d"/>
      </elt1>
      <elt1 att1="a" att2="d">
              <subelt1 att1="x"/>
      </elt1>
      <elt2 att1="d"/>
      <elt3 att1="e"/>
</root>

So the following rules must be respected:
. Each element associated with its attribute is unique (we don't have two
<elt1 att1="a" att2="b">).
. If one element exists only in one of the file, it should  appear in the
output.


The online chapter of Sal Mangano's XSLT Cookbook may shed some light
on this. Check out:

http://www.oreilly.com/catalog/xsltckbk/chapter/ch07.pdf

(I recommend the whole book as well.) Sorry that I don't have time to
cook up a working sample myself. ;-)

--David Mitchell


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • Merging two xml files, Mulberry Technologies List Owner
    • Message not available
      • Re: Merging two xml files, David Mitchell <=