[4suite] Validation problem
Uche Ogbuji
uche.ogbuji at fourthought.com
Sun Jun 29 23:27:13 MDT 2003
On Sat, 2003-06-28 at 14:05, Matt Gushee wrote:
> As I was getting started on implementing WebDAV support, it occurred to
> me that it might be desirable to validate the XML messages use for
> requests like PROPFIND and PROPPATCH (that's "might be" ... read on).
> However, any of the generic validation methods supported by 4Suite has
> significant drawbacks: DTD validation depends on the xmlproc parser;
> RELAX NG requires Python 2.2 and is said to be experimental (according
> to Uche's Akara as of 6/24). I'm reluctant to introduce such
> dependencies without a very clear need to do so.
Fair enough, but I do plan to make some tweaks needed to solidify the
RELAX NG support before 1.0b2. Good RELAX NG support in 4Suite 1.0 is
pretty important to me.
> Schematron should work
> in any 4Suite installation, but I don't think it's really appropriate
> for this case, since WebDAV needs to return HTTP errors when the XML is
> incorrect.
Well, it wouldn't be too hard to analyze Schematron output to package
error reports into HTTP responses.
> So it occurred to me that it might be useful to have a lightweight
> library for XML validation logic that will work with any XML parser and
> without parsing a schema at runtime. In fact, I've started developing
> just such a library: I call it MiniVal (Mini Validator). When you want
> to validate a document, you feed it the parsed document, a "MiniVal
> Schema" (MVS), and a set of functions for extracting the necessary info
> from the document. The MVS is an abstract XML schema in the form of a
> Python data structure; it should be fairly easy to generate an MVS from
> an ordinary DTD, RNG schema, or whatever.
Very, very cool idea, I must say.
> Now, roughing out this library is actually pretty simple. I've done about
> 2 hours of work on it, and can probably have something usable in another
> 2-3 hours. On the other hand, I think it will take a great deal of
> effort to be sure that it behaves correctly in all cases. So before
> going any further, I thought I should get some feedback on the concept
> (and if something like this already exists, please let me know).
I haven't encountered anything the like.
> I should emphasize that MVS is *not* intended for general-purpose XML
> validation. The point is to have something you can easily include in an
> application that needs to validate a limited set of simple document
> types, as is the case with WebDAV. The way I see it working is that the
> developer of an application would create MVSs for whatever document
> types the application needs to validate, then bundle those and MiniVal
> along with the application.
Yes. This is exactly how I would imagine the scope of such a tool. But
I think this alone is very valuable. It would provide almost a
design-by-contract framework for XML processing in Python.
> Now, as for the original question, what about WebDAV? The spec doesn't
> require validation per se, and as I have noted the doctypes are pretty
> simple, so it's probably best to just write special-purpose logic for
> the WebDAV module ... certainly I can get that done a lot quicker than a
> robust MiniVal implementation. But I'm still thinking the MiniVal
> concept may be useful for other applications.
I think the MiniVal effort sounds very worthwhile. But I would like to
see your thoughts on what the MVS data structure would look like.
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
XML Data Bindings in Python - http://www.xml.com/pub/a/2003/06/11/py-xml.html
Introducing Examplotron - http://www-106.ibm.com/developerworks/xml/library/x-xmptron/
Charming Jython - http://www-106.ibm.com/developerworks/java/library/j-jython.html
The commons of creativity - http://www-106.ibm.com/developerworks/xml/library/x-think18.html
A custom-fit career in app development - http://www.adtmag.com/article.asp?id=7744
More information about the 4suite
mailing list