Python Tools: Amara XML Toolkit 1.1.9
Amara XML Toolkit Version 1.1.9: Python Tools for XML Processing
Amara XML Toolkit 1.1.9 From: Uche Ogbuji <uche@ogbuji.net> To: xml-dev@lists.xml.org Date: Sep 15, 2006 10:59 PM Subject: Announce: Amara XML Toolkit 1.1.9
http://uche.ogbuji.net/tech/4suite/amara
http://cheeseshop.python.org/pypi/Amara/
ftp://ftp.4suite.org/pub/Amara/
Changes since Amara Version 1.1.7:
- Add support for EasyInstall; other packaging & installer improvements - Note: allinone package eliminated
- Add trimxml command line utility (for running reports on XML files)
- Switch to Docbook for documentation source
- Bindery: Add support for dict-like accessors
- Tenorsax: Restore support for PySax
- Scimitar: Implement abstract rules
- Scimitar: Update Schematron namespace to ISO
- Scimitar: Implement phases
- Scimitar: Support Schematron queryBinding attribute: XPath, XSLT, EXSLT
- Add binderytools.fixup_namespaces function
- Add binderytools.quick_xml_scan function
- Fix APIs for adding comments and PIs
- Fix domtools.abs_path to be more namespace aware
- Bug fixes
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's conventions and take advantage of the many advantages of the language.
Amara builds on 4Suite [http://4Suite.org], but whereas 4Suite offers 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 corresponding to the vocabulary used in the XML document, for maximum clarity. For example, the document
<monty> <python spam="eggs">What do you mean "bleh"</python> <python ministry="abuse">But I was looking for argument</python> </monty>
Becomes a data structure such that you can write
binding.monty.python.spam
In order to get the value "eggs" or
binding.monty.python [1]
In order to get the value "But I was looking for argument".
There are other such tools for Python, and what makes Bindery 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 fairly efficient, using SAX to generate bindings.
Scimitar: Schematron for Pytthon --------------------------------
Scimitar is an implementation of ISO Schematron that compiles a Schematron schema into a Python validator script.
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, scimitar.py:
scimitar.py schema1.sch
The generated file, schema1-stron.py, can be used to validate XML instances:
python schema1-stron.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 machine wizardry.
License -------
Amara is open source, provided under the 4Suite variant of the Apache license. See the file COPYING for details.
Installation ------------
Amara 1.1.9 requires Python 2.3 or more recent and 4Suite-XML 1.0rc4 or more recent. The easiest way to install it is:
easy_install amara
If this does not work you are probably not set up for easy_install and I suggest you follow the simple instructions at
http://peak.telecommunity.com/DevCenter/EasyInstall
easy_install will automatically take care of installing dependencies for you. If you prefer not to use easy_install, then grab a 4Suite-XML package morerecent than 1.0rc4 and install that, then install the Amara package using the usual:
python setup.py install
Or a Windows installer, or other method.
-- Uche Ogbuji Fourthought, Inc. http://uche.ogbuji.net http://fourthought.com http://copia.ogbuji.net http://4Suite.org Articles: http://uche.ogbuji.net/tech/publications/
Prepared by Robin Cover for The XML Cover Pages archive. See: "XML and Python."