I added a demo package to illustrate the zope3 / xml schema integration.

You can grab de code over there :


The goal of the demo is to get a new content object registred within Zope3
with an "add "and "edit" form driven by an XML Schema definition.

This example is pretty simple but illustrate perfectly the goal of the XML
integration and the power of Zope3 ;)

Let's take a look at the xsd we will use in this demo  :

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:attribute name="title" use="required" type="xs:normalizedString" />

<xs:attribute name="description" use="required" type="xs:string"/>



It defines a schema having 2 attributs : title and description.

title is required and is a normalizedString data type

description is required as well and is a string data type.

Let's define an interface IFoo and set the "foo" schema above. Note I'm
using directly an id in here for the schema (i.e : foo). This is because at
this stage the schema will be registred within Zope3 under this name. We
will see how just after.

import zope.interface

import zope.xmlschema

class IFoo(zope.interface.Interface):



Then define the Foo content object implementing IFoo. It inherits from
presistent so that the content object will be persistent but it's not

import persistent

import zope.interface

from zope.xmlschema.demo.interfaces import IFoo

class Foo(persistent.Persistent):


def init(self, title='', description=''):

self.title = title

self.description = description


Now the zcml configuration (the glue) (see demo.configure.zcml) to tell
Zope what to do whith the definitions above.

Let's take a look at the configure.zcml file for the package as explained
below :


id = "foo"

document ="foo.xs"



This directive registers the xsd foo.xs under the name of 'foo'

Then the one below defines the new content object (notice the set_schema
directive.) You can forget about the Zope permission stuffs if you're not
familiar with Zope3

<content class=".foo.Foo">


interface="zope.app.annotation.IAttributeAnnotatable" />

<require permission="zope.View"

interface=".interfaces.IFoo" />

<require permission="zope.ManageContent"

set_schema=".interfaces.IFoo" />


Then, we specify the add and edit form for the Foo content object.



label="Add a Foo content object"


arguments="title description"






label="Edit Foo"


menu="zmi_views" title="Edit"



Then we need to tell Zope to add an entry in ZMI (Zope Management
Interface) menu for us to be able to create a Foo content object through the







Now start Zope3 go in the ZMI and click the Add menu entry and ask for the
creation of a Foo content object.

You will get the form below :

Then you can try to submit with empty values and since we specified
required values on the xml schema the submission is not possible :

Here it is for today.

The 'magic' for the rendering against the schema is done by Zope3 itself.
It's not the job of the zope.xmlschema component.

Again, the next step will be to have the rendering done with XForms :)
Currently, looking at it. I played today with the mozilla xforms plugin.
I'll dig into this whike coming back from holidays at the beginning of

Time to sleep...

(Post originally written by Julien Anguenot on the old Nuxeo blogs.)