Python & XML & DTD (warning: noob attack!)

Peter Hansen peter at engcorp.com
Thu Jan 29 09:44:25 EST 2004


Igor Fedorow wrote:
> 
> I have an XML file with an internal DTD which looks roughly like this:
> [snip]
> I want to parse this file into my application, modify the data (this includes
> maybe creating and/or deleting nodes), and write it back into the file --
> including the DTD. (It doesn't necessarily need validation, though.)
> 
> I tried xml.dom.ext.PrettyPrint, but it produces only
> [snip]
> actually lacking the document type definition.
> 
> Any help is appreciated!

Unfortunately I don't know of any way you could generate the DTD again, 
and I've never seen a package which supports what you ask for (not that
it isn't possible, mind you).

On the other hand, are you sure you need the DTD?  We use XML in
dozens of ways and absolutely have never benefited from attempts 
to use DTDs, and don't appear to suffer from the lack thereof.  

Also, aren't DTDs sort of considered either obsolete or at least
vastly inferior to the newer approaches such as XML Schema, or both?

So my recommendation is to ditch the DTD and see if any problems 
arise as a result.

-Peter



More information about the Python-list mailing list