Craeg,
> Here are the forces:
>
> - there are many types of schemas: DTD, RelaxNG, Schematron, XML-Schema
> - the changes any given processor library will implement *all four* are
> virtually nil
> - DTD is different b/c it is mentioned in the document, the others are
> linked externally
That is not entirely true. First, DTD can be declared *in* the XML
document (inline), but as a separate entity using the PUBLIC or SYSTEM
identifier. Second, I know for a fact that XML-Schema uses an attribute
like xsi:schemaLocations="someuri" in the document element to refer to a
certain schema.
> These forces are leading me towards creating four small Zope classes:
> DTDValidator, RelaxNGValidator, SchematronValidator, XMLSchemaValidator.
I would like to follow the path we have chosen for XPathMethods here.
IMO, we should have four *interfaces*:
* IDTDValidator
* IRelaxNGValidator
* ISchematronValidator
* IXMLSchemaValidator
If you want, they could all inherit from a marker interfaces called
IValidator, but that's overkill. Maybe we'd also like to call them
Processor instead of Validator, in order to be consistent with
IXPathProcessor and IXSLTProcessor.
If a processor implements any of these, it promises that it can do this
kind of validation (just like with IXPathProcessor). Please keep in mind
that those interfaces may not declare any methods of the same name,
because it might very well be that a processor supports more than one
validation.
I'm a little confused about your further questions. First, I think it's
too early to talk about how we design management pages before we don't
have a clear picture of the interfaces; second, I'm not sure how, where
and with what you would like to do the validation.
Will there be an XMLValidateMethod object like XPathMethod or
XSLTMethod? Is this what you meant with "creating four small Zope classes"?
> Also, we need a field for the "Schema Object ID" *only* if it is
> not a DTD.
We don't want to limit this to an object ID, IMO. When we implemented
basic XML-Schema support in Zope3, we followed what XML-Schema and
probably all other standards use: URIs. The schema may be another Zope
object, but it could also be an external source like a W3C XHTML Doctype
which you would not like to copy to your Zope instance, but rather refer
to it using a URI like http://www.w3.org/DTDs/wherever/it/is
Since DTD, XML-Schema (and probably the other standards, too) support
declaring their schema using a URI, I think the default setting for the
validator should be: extract the URI from the document, resolve the URI,
fetch the object (that's going to be a little work, because eventually,
we'd like to support URIs from HTTP; for now, we can just support
relative URIs which will be resolved to Zope objects using
restrictedTraverse()) and evaluate it.
When that whole chain fails, either because there is no URI declaration,
or the URI leads to nothing, you should be able to enter a different URI.
> The alternative is four small classes. Problem is in Zope2 inheritance
> is broken, so we can't create a Validator base class, right? IIRC
> this is because of the fact that Zope2 uses a special base class
> for persistence written in C that does not obey all of the normal
> Python rules wrt inheritance.
I think you're confusing things here. It is correct that persistent
classes with ZODB3 (i.e. Zope2) use ExtensionClass as the ultimate base
class which in some circumstances behaves differently than standard
python classes, but inheritance is still working!
Hope that helps,
Philipp
|