[
Lists Home |
Date Index |
Thread Index
]
http://uche.ogbuji.net/tech/4Suite/amara
ftp://ftp.4suite.org/pub/Amara/
Changes in this release:
* Use local names rather than QNames for default bindings
* Add attribute support to XPath
* Add amara.binderytools.preserve_attribute_details rule
* Reorg and fix demos and tests
* Add Flextyper DTLL implementation
* Add parsing functions binderytools.bind_string,
binderytools.bind_stream
* Add binderytools.pushbind. This one deserves some elaboration.
The following is complete code for iterating through address labels in
an
XML document, while never loading more memory than needed to hold one
label
element:
from amara import binderytools
for subtree in binderytools.pushbind('/labels/label',
source='labels.xml'):
print subtree.label.name, 'of', subtree.label.address.city
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 (fancy way of saying: 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
--------------------------------
Based on the retired project Anobind, but updated to use SAX rather than
DOM
to create bindings. Bindery reads an XML document and returns a data
structure of Python objects corresponding to the vocabulary used in the
XML document, for maximum clarity.
Bindery turns the document
<monty>
<python spam="eggs">What do you mean "bleh"</python>
<python ministry="abuse">But I was looking for argument</python>
</monty>
Into a set of objects 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 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: exceptional schema language for an exceptional programming
language
-----------------------------------------------------------------------------
Merged in from a separate project, 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.stron
A file, schema1.py is generated and 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 machine
wizardry.
License
-------
Amara is open source, provided under the 4Suite variant of the Apache
license. See the file COPYING for details.
Installation
------------
Amara requires Python 2.3 or more recent and 4Suite 1.0a3 or more
recent. Make sure these are installed, unpack Amara to a convenient
location and run
python setup.py install
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
Use CSS to display XML - http://www.ibm.com/developerworks/edu/x-dw-x-xmlcss-i.html
Full XML Indexes with Gnosis - http://www.xml.com/pub/a/2004/12/08/py-xml.html
Be humble, not imperial (in design) - http://www.adtmag.com/article.asp?id=10286
UBL 1.0 - http://www-106.ibm.com/developerworks/xml/library/x-think28.html
Use Universal Feed Parser to tame RSS - http://www.ibm.com/developerworks/xml/library/x-tipufp.html
Default and error handling in XSLT lookup tables - http://www.ibm.com/developerworks/xml/library/x-tiplook.html
A survey of XML standards - http://www-106.ibm.com/developerworks/xml/library/x-stand4/
The State of Python-XML in 2004 - http://www.xml.com/pub/a/2004/10/13/py-xml.html
|