merging 2 xml into 1

Discussion in 'XML' started by Mael Guillemot, Jul 4, 2003.

  1. 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
     
    Mael Guillemot, Jul 4, 2003
    #1
    1. Advertising

  2. Mael Guillemot wrote:

    > 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

    <xsl:copy-of select="document('shots.xml')/video/shot[@id = $thisid]" />



    --
    Klaus Johannes Rusch

    http://www.atmedia.net/KlausRusch/
     
    Klaus Johannes Rusch, Jul 4, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JNU
    Replies:
    3
    Views:
    361
    Roedy Green
    Sep 3, 2003
  2. Mark
    Replies:
    3
    Views:
    697
    Oliver Wong
    Mar 31, 2006
  3. =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=

    Merging sorted lists/iterators/generators into one stream of values...

    =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=, Oct 6, 2005, in forum: Python
    Replies:
    24
    Views:
    734
    =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=
    Oct 11, 2005
  4. Replies:
    2
    Views:
    17,377
    Philippe Poulard
    Aug 24, 2006
  5. q-rious
    Replies:
    2
    Views:
    851
    Manuel Collado
    Mar 13, 2011
Loading...

Share This Page