InitialNotes
Zope/XML Integration
Goals
XML -> Zope
Loading XML text creates objects
Loading XML text causes objects to be created. These objects are DOM objects and Zope objects.
Assigning behavior
A mapping can be defined for assigning classes to elements. The classes can be ZClasses? or regular Python classes that have been registered during product initialization.
The mapping is namespace aware. In fact, we may require that namespaces be Iused. Perhaps we can provide an option during import to specify a default namespace.
A class can register for more than 1 tag. A class can register as the default for a namespace.
Should there be a way to register a class for an attribute?
Should we instantiate id and idref links? (Probably)
Validation
We should provide optional validation support. This might be achieved in a number of ways:
- Let custom instances perform validation during building.
- Embed validation rules in custom in custom class definitions.
- Use validation rules (e.g. state machine) compiled and cached from data such as DTDs? and other kinds of schema information.
Custom-object parsing protocol
How are instances created? In particular, what protocols do custom classes have to support when constructcd? Are there existing standards for this? Some posibilities:
- Call constuctor wlth sequence of sub-elements and attribute mapping
def __init__(self, elements, attributes)
This is simple, but pretty XML specific. We also don't get to build the object until the subobjects are built.
- Call constructor with parent node and attributes and call
addElement with each element.
def __init__(self, parent, attributes)
def addElement(self, element)
Maybe after after creating an element, we use it in the context of the parent:
e=aClass(p,a)
p.addElement(e)
e=e.__of__(p)
- Does the DOM define this?
Optimization
Not every element should be a database object
How do we decide which?
- Custom class
- Elements known, from schema information, to have subobjects are persistent.
- Elements start out non-persistent and are made persistent when they get subelements.
Want an efficient data structure, especially for standard XML objects