merging 2 xml into 1

merging 2 xml into 1

Post by Mael Guillemo » Sat, 05 Jul 2003 18:00:50



Hi,

I have one xml looking like this:

=========================
<video>
    <shot id="1">
        <timestampbegin>000030.90</timestampbegin>
        <feature>blabla</feature>
        <timestampbegin>000045.20</timestampbegin>
    </shot>
    <shot id="2">
....
</video>
=========================

Another xml gives simple information about the clustering of video shots
into scenes looking like that:

=========================
<video>
    <scene id="1">
            <shot id="1"></shot>
            <shot id="4"></shot>
            <shot id="5"></shot>
     </scene>
    <scene id="2">
            <shot id="2"></shot>
            <shot id="3"></shot>
            <shot id="6"></shot>
            <shot id="7"></shot>
   </scene>
....
</video>
=========================

I wish to merge both XML into one like:

=========================
<video>
    <scene id="1">
        <shot id="1">
            <timestampbegin>000030.90</timestampbegin>
            <feature>blabla</feature>
            <timestampbegin>000045.20</timestampbegin>
        </shot>
        <shot id="4">
......................
        </shot>
        <shot id="5">
.....................
        </shot>
     </scene>
    <scene id="2">
            <shot id="2"> ............................... </shot>
            <shot id="3"> ............................... </shot>
            <shot id="6"> ............................... </shot>
            <shot id="7"> ............................... </shot>
   </scene>
.......
</video>
=========================

Does anybody know how this kind of simple merging can be done?? using
simple perl with XML::simple or xerces or xalan???

thanks for any hints,

Ma?l

 
 
 

merging 2 xml into 1

Post by Klaus Johannes Rusc » Sat, 05 Jul 2003 19:59:08



> I have one xml looking like this:

> =========================
> <video>
>     <shot id="1">
>         <timestampbegin>000030.90</timestampbegin>
>         <feature>blabla</feature>
>         <timestampbegin>000045.20</timestampbegin>
>     </shot>
>     <shot id="2">
> ....
> </video>
> =========================

> Another xml gives simple information about the clustering of video shots
> into scenes looking like that:

> =========================
> <video>
>     <scene id="1">
>             <shot id="1"></shot>
>             <shot id="4"></shot>
>             <shot id="5"></shot>
>      </scene>
>     <scene id="2">
>             <shot id="2"></shot>
>             <shot id="3"></shot>
>             <shot id="6"></shot>
>             <shot id="7"></shot>
>    </scene>
> ....
> </video>
> =========================

> I wish to merge both XML into one like:

> =========================
> <video>
>     <scene id="1">
>         <shot id="1">
>             <timestampbegin>000030.90</timestampbegin>
>             <feature>blabla</feature>
>             <timestampbegin>000045.20</timestampbegin>
>         </shot>
>         <shot id="4">
> ......................
>         </shot>
>         <shot id="5">
> .....................
>         </shot>
>      </scene>
>     <scene id="2">
>             <shot id="2"> ............................... </shot>
>             <shot id="3"> ............................... </shot>
>             <shot id="6"> ............................... </shot>
>             <shot id="7"> ............................... </shot>
>    </scene>
> .......
> </video>
> =========================

> Does anybody know how this kind of simple merging can be done?? using
> simple perl with XML::simple or xerces or xalan???

XSLT looks like a good choice for this problem (of course you can do this in
Perl as well by parsing the documents and processing the document trees in
Perl).

I would recommend the following approach:  Use the second document (scenes)
as your primary document, process each scene in sequence and pull in shot
information from the other file using the document() function, something
like


--
Klaus Johannes Rusch

http://www.atmedia.net/KlausRusch/

 
 
 

1. Merging 2 XML files into 1 XML file

Hi Friends,

I have an XML file, something like this
--------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<company id="132">
        <user id="1" name="John Smith" />
</company>
--------------------------------------------
And a second XML which looks like this
--------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<company id="132">

</company>
--------------------------------------------

I would like to merge the 2 XML files and create 1 XML
file which has all the data in it.

The merged(output) XML file looks something like this.
--------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<company id="132">

</company>
--------------------------------------------

What is the easiest method to achive this.
I know that i could use XMLDocument object to read the
nodes of each file and then merge them programatically.
But i would not like to do that.

Can i use XSL to achive this.
Or should i use "DataSet.merge"  method?

I would prefer doing it through XSL, is it possible to do
this with XSL?

I will really appreciate any help/guidance!!

Many Thanks!

Regards,
Mohit

2. Converting Microsoft Word database to Frontpage?

3. How do I merge 2 xml files into 1 xml file using xsl?

4. Fullpack trap 000d errors in tutorial

5. merge several XML files to (one) XML file

6. Memory from TRG

7. merge/concatenate XML files using XML schema

8. Utility to merge multiple XML files to one XML file.

9. Merging an XML String into another XML Document

10. Merge multiple XML files

11. Word Mail Merge --> XML according to a defined DTD

12. Tool to Merge Multiple XML Files With XSL