Hi,
I'm trying to write a script that uses diffxml along with 4xupdate
to merge XML files. So far, I'm having trouble with even the most
basic files. I have tried different versions of the components, to no
avail. Are there any alternatives? I've put sample files below.
Thanks,
Eyal.
====================================
I want to merge this:
<?xml version="1.0"?>
<root>
<codecs a="10" b="20" />
<timeouts c="10" d="20" e="30" />
<reporting f="10" g="20" />
<lims h="10" />
</root>
with this (note the difference in the reporting node. If the reporting
node does not change, or attributes are added, but none are removed,
4xupdate works):
<?xml version="1.0"?>
<root>
<codecs a="1" b="2" />
<timeouts c="1" d="2" e="3" />
<reporting f="1" z="3" />
<lims h="1">
<lim0 i="1" />
<lim1 i="2" />
<lim2 i="3" />
<lim3 i="4" />
</lims>
<HW j="1" />
</root>
and I get a bunch of errors:
Traceback (most recent call last):
File "/usr/bin/xmldiff", line 5, in ?
xmldiff.run(*sys.argv)
File "/usr/lib/python2.3/site-packages/logilab/xmldiff/xmldiff.py",
line 218, in run
encoding, html)
File "/usr/lib/python2.3/site-packages/logilab/xmldiff/xmldiff.py",
line 114, in process_files
strategy.process_trees(tree1, tree2)
File "/usr/lib/python2.3/site-packages/logilab/xmldiff/fmes.py", line
104, in process_trees
self._formatter.end()
File "/usr/lib/python2.3/site-packages/logilab/xmldiff/format.py",
line 212, in end
AbstractFormatter.end(self)
File "/usr/lib/python2.3/site-packages/logilab/xmldiff/format.py",
line 80, in end
self.format_action(action)
File "/usr/lib/python2.3/site-packages/logilab/xmldiff/format.py",
line 203, in format_action
self._stream.write(action[A_N2])
TypeError: argument 1 must be string or read-only character buffer, not
list
and a diff file looking like this:
<?xml version="1.0"?>
<xupdate:modifications version="1.0"
xmlns:xupdate="http://www.xmldb.org/xupdate">
<xupdate:insert-after select="/root[1]/reporting[1]" >
<xupdate:element name="lims"> <xupdate:attribute
name="h">1</xupdate:attribute>
<lim0 i="1"/>
<lim1/>
<lim2 i="3"/>
<lim3 i="4"/>
</xupdate:element>
</xupdate:insert-after>
<xupdate:rename select="/root[1]/lims[2]" >HW</xupdate:rename>
<xupdate:append select="/root[1]/reporting[1]" > <xupdate:attribute
name="z">3</xupdate:attribute>
</xupdate:append>
<xupdate:rename select="/root[1]/HW[1]/@h" >j</xupdate:rename>
<xupdate:update select="/root[1]/codecs[1]/@a" >1</xupdate:update>
<xupdate:update select="/root[1]/codecs[1]/@b" >2</xupdate:update>
<xupdate:update select="/root[1]/timeouts[1]/@c" >1</xupdate:update>
<xupdate:update select="/root[1]/timeouts[1]/@d" >2</xupdate:update>
<xupdate:update select="/root[1]/timeouts[1]/@e" >3</xupdate:update>
<xupdate:update select="/root[1]/reporting[1]/@f" >1</xupdate:update>
<xupdate:rename select="/root[1]/reporting[1]/@g" >i</xupdate:rename>
<xupdate:move select="[2, '@iName', 'i', [[3, '@i', '2', [], [...], 0,
1, 1, 1]], [1, 'lim1', 'lim1', [[...]], [1, 'lims', 'lims', [[2,
'@hName', 'h', [[3, '@h', '1', [], [...], 0, 1, 1, 1]], [...], 1, 1, 1,
1], [1, 'lim0', 'lim0', [[2, '@iName', 'i', [[3, '@i', '1', [], [...],
0, 1, 1, 1]], [...], 1, 1, 1, 1]], [...], 2, 1, 1, 1], [...], [1,
'lim2', 'lim2', [[2, '@iName', 'i', [[3, '@i', '3', [], [...], 0, 1, 1,
1]], [...], 1, 1, 1, 1]], [...], 2, 1, 1, 1], [1, 'lim3', 'lim3', [[2,
'@iName', 'i', [[3, '@i', '4', [], [...], 0, 1, 1, 1]], [...], 1, 1, 1,
1]], [...], 2, 1, 1, 1]], [1, 'root', 'root', [[1, 'codecs', 'codecs',
[[2, '@aName', 'a', [[3, '@a', '1', [], [...], 0, 1, 1, 1]], [...], 1,
0, 1, 1], [2, '@bName', 'b', [[3, '@b', '2', [], [...], 0, 1, 1, 1]],
[...], 1, 0, 1, 1]], [...], 4, 1, 1, 1], [1, 'timeouts', 'timeouts',
[[2, '@cName', 'c', [[3, '@c', '1', [], [...], 0, 1, 1, 1]], [...], 1,
0, 1, 1], [2, '@dName', 'd', [[3, '@d', '2', [], [...], 0, 1, 1, 1]],
[...], 1, 0, 1, 1], [2, '@eName', 'e', [[3, '@e', '3', [], [...], 0, 1,
1, 1]], [...], 1, 0, 1, 1]], [...], 6, 1, 1, 1], [1, 'reporting',
'reporting', [[2, '@fName', 'f', [[3, '@f', '1', [], [...], 0, 1, 1,
1]], [...], 1, 0, 1, 1], [2, '@zName', 'z', [[3, '@z', '3', [], [...],
0, 1, 1, 1]], [...], 1, 1, 1, 1]], [...], 4, 1, 1, 1], [...], [1, 'HW',
'HW', [[2, '@jName', 'j', [[3, '@j', '1', [], [...], 0, 1, 1, 1]],
[...], 1, 1, 1, 1]], [...], 2, 1, 1, 1]], [6, '/', '', [[...]], None,
21, 0, 0, 1], 20, 1, 1, 1], 14, 1, 1, 1], 2, 1, 1, 1], 1, 1, 0, 1]" >