Generating XML: testers and feedback wanted

Jerome Alet alet at unice.fr
Wed Sep 13 06:02:35 EDT 2000


Hi,

I've just written a new module to easily generate nice looking XML
documents.

Since I'm not an XML regular user nor lawyer I'd be very pleased if some
people wanted to test it and send me some feedback.

Here's the documentation:

This python module defines a class named XML_document which will
allow you to generate XML documents (yeah !) more easily than
using print or similar functions.

Here's a list of available methods:
===================================

        __init__(version, encoding)
                The instance constructor, automatically called
                when you create a new instance of XML_document.
                you can optionnally pass a version and encoding
                string, the defaults are "1.0" and "iso-8859-1".

        _indentstring(istr)
                istr is now the new indentation string used
                to nicely present your XML documents. By
                default istr is equal to 4 space characters.

        _output(filearg)
                use it to save the XML document to a file.
                filearg may be:
                    None, "", or "-" which stands for sys.stdout.
                    a file name.
                    any file object.

        _text(sometext)
                use it to insert plain text at the current position
                in the document.

        _push()
                saves the current position in the XML document.
                use it if you're going to create a bungh of imbricated
                XML tags and want to escape from them later to continue
                your document at the same indentation level.

        _pop()
                restores the latest saved position.
                use it toi escape from imbricated tags and continue
                your XML document at the same indentation level than
                the latest time you called _push().

        ANY other method you may call will be treated as an XML
tag, unless you subclass XML_document to add your own methods, but
I suggest you to only add methods whose names begin with '_' to keep
things simple and clear.

The file sampleXML.py is an example program which generates
an XML document, just play with it (use and modify) and you'll
learn quickly how to use jaxml.

The only difficult things are:
------------------------------

        * you have to use the _push() and _pop() methods if you need
          to get out of a bunch of imbricated tags.

        * if you call a method (tag) with a string as the first
          unnamed parameter, you'll don't need _push() or _pop()
          because your tag will be automatically closed immediately.

----------------------------------------------------------

The license is GPL (no joke)

You can find it at: http://cortex.unice.fr/~jerome/jaxml/

look at the code and sample or download the tarball.

thanks in advance for any form of feedback (constructive flames are
welcome too)

-- 
Jerome ALET - alet at unice.fr - http://cortex.unice.fr/~jerome
Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30 
28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE



More information about the Python-list mailing list