Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Merging two XML tree: xslt or dom ?

Reply
Thread Tools

Merging two XML tree: xslt or dom ?

 
 
Yannick Patois
Guest
Posts: n/a
 
      07-20-2004
Hi,

I would like to merge two XML document, or more exacly enrich a document
by inheritiong from another.

I read a bit about XSLT and I know a bit of python/sax/dom, and I dont
know where I should go. I tried xslt, without success yet (but I dont
know much about it) so I failed back on python+dom wher I know a bit more.

I'm asking you if it's a good choice, or if I should use XSLT for this.

Small example of what I want:

File1:
<toto>
<tata>bla</tata>
<titi>bli</titi>
<toto>

File2:
<toto>
<tata>bla bla</tata>
<tutu>blu</tutu>
<toto>

Result:
<toto>
<tata>bla bla</tata>
<titi>bli</titi>
<tutu>blu</tutu>
<toto>

Note that <tata> value has been supereseded by file2 value, and <titi>
added as not present in file2. To me, it must look like OO "inheritance"
property, even if I dont know if this has any meaning for XML.

More concrelty, it's about compilation commands to issue for a given
file, right now I represent them like this (prototype):

<package name="default">
<spi_configure>
<command name="./configure" argument="$SPI_PREFIX"/>
</spi_configure>
<spi_make>
<command name="make" />
</spi_make>
<spi_makeinstall>
<command name="make" argument="install" />
</spi_makeinstall>
<spi_check>
<command name="make" argument="check" />
</spi_check>
</package>


<package name="foo" version="1.0.0">
<spi_make>
<command name="make" argument="all" />
<command name="make" argument="dylibs" />
</spi_make>
</package>


The package "foo" build exactly like the default procedure, except that
the make step is a bit different. That's what I need to express by
creating a new xml file containing all the informations. Then I know how
to convert this to bash or whatever using xslt.

Thanks for any help.

Yannick

--
_/ Yannick Patois \_________________________________________________ __
| web: http://feelingsurfer.net/garp/ | Garp sur irc undernet |
| email: http://www.velocityreviews.com/forums/(E-Mail Removed) | |
| ATTAC dans le Pays de Gex: http://attacgex.ouvaton.org |
 
Reply With Quote
 
 
 
 
Uche Ogbuji
Guest
Posts: n/a
 
      07-23-2004
Yannick Patois <(E-Mail Removed)> wrote in message news:<cdiokd$jil$(E-Mail Removed)>...
> Hi,
>
> I would like to merge two XML document, or more exacly enrich a document
> by inheritiong from another.
>
> I read a bit about XSLT and I know a bit of python/sax/dom, and I dont
> know where I should go. I tried xslt, without success yet (but I dont
> know much about it) so I failed back on python+dom wher I know a bit more.
>
> I'm asking you if it's a good choice, or if I should use XSLT for this.
>
> Small example of what I want:
>
> File1:
> <toto>
> <tata>bla</tata>
> <titi>bli</titi>
> <toto>
>
> File2:
> <toto>
> <tata>bla bla</tata>
> <tutu>blu</tutu>
> <toto>
>
> Result:
> <toto>
> <tata>bla bla</tata>
> <titi>bli</titi>
> <tutu>blu</tutu>
> <toto>
>
> Note that <tata> value has been supereseded by file2 value, and <titi>
> added as not present in file2. To me, it must look like OO "inheritance"
> property, even if I dont know if this has any meaning for XML.


You can use DOM or XSLT for this. For an example of the latter, see:

http://aspn.activestate.com/ASPN/Coo.../Recipe/135131

With XSLT, you're going to need the document() function, then you'll
need to set up templates for each level of the doc that could be
merged, using various tricks to keep the contexts of both source
documents in sync.

I'd think it easier in DOM.

Good luck.

--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
Perspective on XML: Steady steps spell success with Google -
http://www.adtmag.com/article.asp?id=9663
Use XML namespaces with care -
http://www-106.ibm.com/developerwork.../x-namcar.html
Managing XML libraries - http://www.adtmag.com/article.asp?id=9160
Commentary on "Objects. Encapsulation. XML?" -
http://www.adtmag.com/article.asp?id=9090
A survey of XML standards -
http://www-106.ibm.com/developerwork...rary/x-stand4/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
merging two sequences in xslt JMan XML 7 10-15-2008 04:47 PM
XSLT sorting / merging / summing david.paik@huscointl.com XML 0 09-20-2006 02:12 PM
Merging XML documents into a single XML file daniel.knights@sunderland.ac.uk XML 2 08-24-2006 01:48 PM
xslt merging question rottyguy70@yahoo.com XML 4 11-01-2005 05:14 PM
merging two XML files Stefan Franke XML 5 01-04-2005 09:23 PM



Advertisments