[Docstring-develop] Re: [XML-SIG] Validation from Python code?

Garth T Kidd garth@deadlybloodyserious.com
Mon, 30 Jul 2001 09:02:37 +1000


> > Basically I'm looking for the XML/DOM equivalent of regular
> > expression matching, something that can answer the question:
> > "given a pattern P, is DOM tree D valid?"
>
> Sounds like you want pytrex.

PyTREX looks like it can nicely validate the parser output (via
``.asdom().toxml()``), but doesn't seem to provide tools for
automatically generating the patterns from the DTD.

Can anyone suggest a way of filling the gap so that we don't have to
hand-maintain the tests in sync with the DTD?

Suspicions: if we switch to using an XML schema, perhaps we can pull
PyTREX patterns out of the schema using XSLT. Perhaps we can build the
schema from the PyTREX patterns. Perhaps we can establish some
middle-format from which we can derive both schema and patterns --
`permittedContents` attributes in ``nodes.py``, or something. It's a fun
problem to mull over, that's for sure.

I can understand David's reluctance to use an external parser if he can
possibly avoid it; it just took me Much Work to get PyXML and 4Suite to
build and install under Cygwin.

David, are you intending your tests to be run only during testing, or as
an optional "paranoid mode" for dps and restructuredtext where people
can have all of their output checked for validity versus the DTD? Both?

Regards,
Garth.