ANN: Amara XML Toolkit 1.1.6
uche.ogbuji at fourthought.com
Fri Oct 28 22:29:37 CEST 2005
Changes since Amara 1.0:
* Use Saxlette over Python stdlib SAX
* Move from threads to generators for pushdom/pushbind
* Simplify API. Make most key functions available from the amara module
* Change node.xml_remove_child to take the child object to be removed
* Add node.xml_remove_child_at which takes the index
(as node.xml_remove_child used to)
* Big performance improvements
* Add xml_parse_fragment
* Add quick reference
* Add support for PIs and comments in XPath
* Allow custom bindings for processing instructions
* Upate date/time handling in type inferencer to use Gustavo Niemeyer's
dateutil, if available ( http://labix.org/python-dateutil )
* Packaging fixes
* Bug fixes and documentation improvements
Amara XML Toolkit is a collection of Python tools for XML processing--
not just tools that happen to be written in Python, but tools built from
the ground up to use Python idioms and take advantage of the many
advantages of Python.
Amara builds on 4Suite [http://4Suite.org], but whereas 4Suite focuses
more on literal implementation of XML standards in Python, Amara
focuses on Pythonic idiom. It provides tools you can trust to conform
with XML standards without losing the familiar Python feel.
The components of Amara are:
* Bindery: data binding tool (a very Pythonic XML API)
* Scimitar: implementation of the ISO Schematron schema language for
XML; converts Schematron files to Python scripts
* domtools: set of tools to augment Python DOMs
* saxtools: set of tools to make SAX easier to use in Python
* Flextyper: user-defined datatypes in Python for XML processing
There's a lot in Amara, but here are highlights:
Amara Bindery: XML as easy as py
Bindery turns an XML document into a tree of Python objects
the vocabulary used in the XML document, for maximum clarity. For
<python spam="eggs">What do you mean "bleh"</python>
<python ministry="abuse">But I was looking for argument</python>
Becomes a data structure such that you can write
In order to get the value "eggs" or
In order to get the value "But I was looking for argument".
There are other such tools for Python, and what makes Anobind unique is
that it's driven by a very declarative rules-based system for binding
XML to the Python data. You can register rules that are triggered by
XPattern expressions specialized binding behavior. It includes XPath
support and supports mutation. Bindery is very efficient, using SAX
to generate bindings.
Scimitar: Schematron for Pytthon
Merged in from a separate project, Scimitar is an implementation of ISO
Schematron that compiles a Schematron schema into a Python validator
You typically use scimitar in two phases. Say you have a schematron
schema schema1.stron and you want to validate multiple XML files
against it, instance1.xml, instance2.xml, instance3.xml.
First you run schema1.stron through the scimitar compiler script,
The generated file, schema1.py, can be used to validate XML instances:
python schema1.py instance1.xml
Which emits a validation report.
Amara DOM Tools: giving DOM a more Pythonic face
DOM came from the Java world, hardly the most Pythonic API possible.
Some DOM-like implementations such as 4Suite's Domlettes mix in some
Pythonic idiom. Amara DOM Tools goes even further.
Amara DOM Tools feature pushdom, similar to xml.dom.pulldom, but
easier to use. It also includes Python generator-based tools for
DOM processing, and a function to return an XPath location for
any DOM node.
Amara SAX Tools: SAX without the brain explosion
Tenorsax (amara.saxtools.tenorsax) is a framework for "linerarizing" SAX
logic so that it flows more naturally, and needs a lot less state
Amara is open source, provided under the 4Suite variant of the Apache
license. See the file COPYING for details.
Amara 1.1.6 requires Python 2.4 or more recent. If you do not have
4Suite XML 1.0b2, grab the Amara-allinone package. If you already have
4Suite XML installed, grab the stand along Amara package. In either
unpack to a convenient location and run:
python setup.py install
Uche Ogbuji Fourthought, Inc.
More information about the Python-announce-list