File contents
Welcome to XML Document, a Zope Product for XML support
What is it?
XML Document allows you to use xml objects in the Zope environment.
You can create xml documents in Zope and leverage Zope to format,
query, and manipulate xml.
What is the status of this product?
This release is *alpha* quality. This means that it is not feature
complete, nor is it bug free. This release is also not supported.
This means we will answer questions and fix problems as time
permits.
Where is XML Document going?
Right now (March 2000) FourThought is working with Digital Creations
to improve XML Document and Zope's XML support in general. XML
Document will probably be reworked to use 4DOM. This will improve
the quality of the DOM implementation and its interoperability with
PyDOM (which is also converting to 4DOM).
Examples
The included Example.zexp file can be imported into Zope to give you
a working example of how to use XML Document.
Requirements
This release requires Zope 2.0.0 beta 2 or later.
Features
The XML Document product parses xml into a Zopish DOM tree. The
individual elements of the tree are true Zope object with id's,
properties, acquisition support, persistence, etc. The document and
individual sub-elements can be edited trough the management
interface.
By turning xml into Zope objects you can leverage all the Zopish
things you know and love to xml. For example you can format xml with
DTML Methods. You can use URL traversal to locate specific elements
in the DOM. You can acquire methods and call them on specific
elements. You can catalog xml elements.
URL traversal
When xml is parsed into a DOM tree, sub-elements are created and
given ids. You can then use URLs to navigate to specific elements.
URL traversal works in two ways, by *id* and by sequence *index*.
id traversal
This works normally, in the same way can traverse all objects
in the Zope object hierarchy by id. For example,
'myDoc/e5/e7/myMethod'
This URL traverses from an XML Document object with id
'myDoc', to a sub-element with id, 'e5', to a sub-element with
id 'e7' and then to an acquired method with id 'myMethod'.
Since node ids are generated automatically and can change when
the xml content of a document is reparsed, this method of URL
traversal has some short-comings. For example, URLs of this
type probably shouldn't be bookmarked since they could change
when the xml document is changed.
sequence index traversal
This form of traversal uses an element's index within its
parent
rather than its id as URL key. For example,
'myDoc/0/2/myMethod'
This URL traverses from an XML Document object with id 'myDoc'
to it's first sub-element, to that element's second
sub-element
to an acquired method with id 'myMethod'
Sequence and mapping interface
XML Documents and elements support the Python sequence interface
for access to sub-elements. At present this support is limited.
For example in DTML you access sub-elements like so::
<!--#var "myDoc[0][4][1].myMethod()"-->
This calls 'myMethod' on a sub-element which is several levels
deep in the DOM tree.
You can also use the sequence interface to manipulate the DOM
tree. For example::
<!--#call "myDoc[0][1]=myDoc[0][5]"-->
This replaces one sub-node with an other.
In addition, you can access sub-elements by id via the mapping
interface::
<!--#var "myDoc['e5']['e25'][1].myMethod()"-->
This example shows sub-element access via a combination of id and
index style access.
Note, you can not currently access sub-elements via 'getattr'
style access. In other words this won't work::
<!--#var "myDoc.e5.e25.myMethod()"--> # wrong
DOM API support
The DOM tree created by Zope aims to comply with the DOM level one
standard. This allows you to access your xml in DTML or External
Methods using a standard and powerful API.
Currently the DOM support is a little incomplete, and has not be
completely tested.
The DOM tree is not built with the xml-sig's DOM package, because
it requires significantly different node classes.
Another divergence from the DOM API is that DOM attributes are
made available as methods not attributes. These attributes are
named by prepending 'get' to the attribute name. For example, the
'firstChild' attribute is available via the 'getFirstChild'
method.
Note, the XML Document DOM is based on the general purpose Zope
DOM (ZDOM). The XML Document Product provides a superset of the
ZDOM.
ObjectManager API support
XML Documents and elements support the read methods of the
ObjectManger API. These methods include 'objectIds',
'objectValues', and 'objectItems'. For example::
<!--#in "objectValues('book')"-->
<!--#var author--><br>
<!--#/in-->
This would iterate through all sub-elements with a tag name of
'book' and would print the 'author' attribute of each sub-element.
Attributes and properties
XML attributes are mapped to Zope properties. You can edit these
values via the standard Zope property management interface and the
changes are reflected in the xml of an element. You can also edit
attributes by editing the xml and these changes are reflected in
the Zope property interface. You can also use standard Zope
property management methods from DTML and External Methods to
change properties.
Meta types
The meta type of an XML Document is 'XML Document'. The meta type
of sub-Elements of XML Documents is given by their tag name.
Editing xml with the management interface
XML Documents are elements are editable via the management
interface. Documents can be created by uploading xml files.
FTP and PUT
You can edit XML Documents through the ZServer FTP server. You can
also use WebDAV and HTTP PUT to update existing XML Document
objects.
You cannot create new XML Document objects with FTP, WebDAV or
PUT.
Limitations
This release is *alpha* quality.
DOM limitations
The currently DOM implementation is incomplete, and most probably
contains bugs.
No support yet for doctype.
No support yet for specifying encoding.
Futures
The XML Document Product has a long way to go. This is a summary of
planned improvements.
In the short term as time permits, we plan to,
* Verify that the DOM implementation is fairly complete and
correct.
* Improve management interface.
* Improve performance, especially for very large xml documents.
In the longer run plans include,
* Provide an ability to bind ZClasses to specific Element types.
This is similar to ZSQL Method's notion of brains.
* More completely support Zope management and object protocols.
* Provide XML validation services.