OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Combining 2 XML into 1 XML via XSLT

[ Lists Home | Date Index | Thread Index ]

Dave,

I'm a little confused about whether this is a general merge problem 
you are trying to solve or a very specific one.

You seem to have in your output a <vehicle> for each of the input 
<vehicle> elements, but the <header name="Safety"> seem to have been 
merged in the two cases, whereas the <header name="Misc"> is not 
merged. This suggests you have very specific needs here.

In general the merge of 2 XML files is a question of finding the best 
match between them, and then generating a result where the common 
data is not repeated. For a commercial solution, DeltaXML [1] 
provides this by generating a 'full delta' file which is the two 
files combined in one (with common data not repeated) from which it 
is easy to generate a merge - I can provide an XSLT stylesheet to do 
this. The tricky bit is finding the best match in the first place.

In your case though, the <vehicle> elements are identified by an id 
attribute, so would not be merged in the general case.

Do take a look at DeltaXML (you can download a command-line eval copy 
which will work for these small files, and we can provide a key to 
enable it to work on larger files). You can use keys to identify the 
different elements. You would also need to start from two similar 
files, i.e. have the <vehicles> wrapper in both input files.

One other small point: suggest you use xsl:strip-space to get rid of 
the spurious indentation (perhaps the files are not indented in 
originals).

Hope this helps a little.

Robin La Fontaine

[1] http://www.deltaxml.com

At 2:50 pm -0500 11/9/02, Dave Yancey wrote:
>I'm trying to combine two xml files into a single xml file via xslt. 
>I know how to do it using copy-of but certain requirments must be 
>met.
>
>The two xml files are vehicle features. And are similiar.
>
>In the xml there are header nodes and row nodes.
>
>xml1 may contain certain header nodes and row nodes that xml2 doesn't.
>
>In the resulting xml each vehicle must contain the same header and 
>row nodes with the correct values (empty or their existing values).
>
>Here is an example of each xml file and what the result is supposed 
>to look like.
>

...cut

>-----------------------------------------------------------------
>The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
>initiative of OASIS <http://www.oasis-open.org>
>
>The list archives are at http://lists.xml.org/archives/xml-dev/
>
>To subscribe or unsubscribe from this list use the subscription
>manager: <http://lists.xml.org/ob/adm.pl>


-- 
-- -----------------------------------------------------------------
Robin La Fontaine, Director, Monsell EDM Ltd
DeltaXML: "Change control for XML, in XML"
Tel: +44 1684 592 144 Fax: +44 1684 594 504
Email: robin.lafontaine@deltaxml.com      http://www.deltaxml.com




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS