[XML-SIG] XML appropiate for config files of a xml processor?

Thomas B. Passin tpassin@home.com
Thu, 9 Nov 2000 08:34:38 -0500

Stephan Tolksdorf asked -

> this a design question not directly related to Python.
> I'm writing a small homegrown xml processor which is
> intended for transforming xml files to html.
> At the moment it is configurable by config files written
in xml.
> But these config files are not easy to manually read or
edit as you
> have to escape <,>,".
> For example a mapping for a xml-tag could look like
> this:
> <tag xml="example">
>      <start>&lt;p&gt;&lt;p&gt;&lt;b&gt;</start>
>      <end>&lt;/b&gt;&lt;/p&gt;</end>
> </tag>

Don't include the markup in a markup definition!  If you are
defining a starttag, your processor should know to supply
the "<", for example.  There's no reason to include it in
the config definitions.

What's wrong with xslt with <output method='html'/>?

If your config files have only one level of structure, use a
simple file format like


You can easily split this on the separator.  If you need two
levels, use two separators - I have used a back-tick for
this (`) since it rarely appears in ordinary text.  You
first split on the ":", then split each piece on the "`".

Or you can write the config file as a Python dictionary.
You can read it into the program and then convert to a real
dictionary using eval().  A dictionary is reasonably easy to
read and write by hand.  I've done this too.  ANy of these
approachs is extremely simple to code for, and it is easy to
write the config file by hand.


Tom Passin