By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,784 Members | 3,274 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,784 IT Pros & Developers. It's quick & easy.

merging 2 xml into 1

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Kl********@atmedia.net
http://www.atmedia.net/KlausRusch/
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.