[XML-SIG] XML/python approach to "smooshing docs together"?

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sun, 12 Nov 2000 00:52:50 +0100


> All ideas gratefully received...

It is certainly easy to combine the three XML files in a single parse
with a good SAX ContentHandler. Use a PyXML
xml.sax.saxutils.XMLGenerator as a base class, but keep an option in
it to ignore a sequence of starting and closing tags.

When parsing the first document, output

    <host>
    <name>slicker</name>
    <ip-address>221.170.160.25</ip-address>

When parsing the second one, output

    <filesystem>
      <mount-point>/</mount-point>
      <size>84MB</size>
    </filesystem>
    <filesystem>
      <mount-point>/usr/local</mount-point>
      <size>128MB</size>
    </filesystem>

And when parsing the third one, output

    <programs>
      <pgm name="DIFF" path="/usr/bin/diff" />
      <pgm name="MAKE" path="/usr/ccs/bin/make" />
    </programs>
    </host>

If you need more complex merge operations, you can try merging DOM
trees, or use XSLT.

Regards,
Martin