[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Combining 2 XML into 1 XML via XSLT


xslt 2 xml files
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@d...      http://www.deltaxml.com

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.