DTD Parsing

Asun Friere afriere at yahoo.co.uk
Wed Nov 10 00:41:36 EST 2010


On Nov 10, 4:11 pm, Stefan Behnel <stefan... at behnel.de> wrote:

> What's your interest in parsing a DTD if you're not up to validating XML?

Spitting out boilerplate code.

Just at the moment I'm creating a stub XSLT sheet, which creates a
template per element (from a 3rd party DTD with 143 elements, yuk!)
containing nothing more than a apply-templates line listing all
possible child elements and a comment saying 'NOT IMPLEMENTED: %s' %
element_name.  This saves not only typing, but helps me work through
and guards against any clumsy oversight on my part in writing a
translation sheet for an IMO overly large schema.

A few years back I used a similar technique to write some boiler plate
python code where xml was isomorphically represented on a class per
element basis (which will no doubt offend some people's sense of
generalisation, but is none the less an interesting way to work with
XML).

While I'm here and just for the record, (as I don't imagine anyone
would want to use the code I posted above), the line
"file_obj.close()" has no place in a function which is passed an open
file_object.  My apologies.



More information about the Python-list mailing list