<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>Uche Ogbuji: Amara XML Toolkit</title>
    <link href="/main.css" type="text/css" rel="stylesheet"/>
  </head>
  <body>
    <div id="left">
      <div class="sideregion">
        <a href="/">
          <img width="90" alt="Uche Ogbuji" height="120" border="0" src="/images/uche-lizbbq.png"/>
        </a>
      </div>
      <hr/>
      <div class="sidebox">
        <div>
          <a href="http://copia.ogbuji.net/files/uogbuji-pubkey.asc">Public key</a>
        </div>
        <div>
          <a href="/tech/">Tech projects</a>
        </div>
        <div>
          <a href="/tech/publications/">Tech publications</a>
        </div>
        <hr/>
        <div>
          <a href="http://copia.ogbuji.net/blog/">Copia (Weblog)</a>
        </div>
        <div>
          <a href="http://del.icio.us/uche">Bookmarks</a>
        </div>
        <div>
          <a href="mailto:uche@ogbuji.net">e-mail address</a>
        </div>
        <div>
          <a href="http://www.flickr.com/photos/21902936@N00/">Flickr (photos)</a>
        </div>
        <div>
          <a href="http://www.advogato.org/person/Uche/">My Diary</a>
        </div>
        <div>
          <a href="/tech/akara/nodes/2003-01-01/pyxml-akara">Python+XML Akara</a>
        </div>
        <div>
          <a href="http://www.oreillynet.com/weblogs/author/1054">O'Reilly Blog</a>
        </div>
        <div>
          <a href="http://www.xmlhack.com/">xmlhack</a>
        </div>
      </div>
      <div class="sideregion">
        <div>
          <a href="http://validator.w3.org/check/referer">
            <img width="88" alt="Valid HTML 4.01!" height="31" border="0" src="http://www.w3.org/Icons/valid-html401"/>
          </a>
        </div>
      </div>
      <div class="sideregion">
        <div style="text-size: x-small;">
          <a href="http://creativecommons.org/licenses/by-sa/1.0/">
            <img src="http://creativecommons.org/images/public/somerights.gif" alt="Creative Commons License" border="0"/>
          </a>
        </div>
      </div>
      <div class="sideregion">
This work is licensed under a
<a href="http://creativecommons.org/licenses/by-sa/1.0/">Creative Commons License</a>.
  </div>
    </div>
    <div id="middle">
      <h1>
        <title>Uche Ogbuji: Amara XML Toolkit</title>
      </h1>
      <div>
        <p>Amara XML toolkit is an open-source 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 over other programming languages.</p>

<p>Amara builds on 4Suite, but whereas 4Suite focuses more on literal implementation of XML standards in Python, Amara adds a much more Pythonic face to these capabilities.</p>

<p>Amara provides tools you can trust to conform with XML standards without losing the familiar Python feel. The current version is 1.2.0.</p>

<p/>

<p>The components of Amara are:</p>

<ul>
<li>
            <p>
              <em>Bindery</em>: a data binding tool (fancy way of saying it's a very Pythonic XML API)</p>
          </li>
<li>
            <p>
              <em>Scimitar</em>: an implementation of the ISO Schematron schema language for XML, which converts Schematron files to Python scripts</p>
          </li>
<li>
            <p>
              <em>domtools</em>: A set of tools to augment Python DOMs</p>
          </li>
<li>
            <p>
              <em>saxtools</em>: A set of tools to make SAX easier to use in Python</p>
          </li>
</ul>

<p/>

<h2>Get started</h2>

<p>Amara 1.2a2 requires <a href="http://python.org">Python</a> 2.4 and <a href="http://cheeseshop.python.org/pypi/4Suite-XML">4Suite XML 1.0</a>.  The easiest way to get going is using <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a>:</p>

<pre>
          <code>easy_install amara
</code>
        </pre>

<p>easy<em>install will automatically take care of installing dependencies for
you.  If you prefer not to use easy</em>install, then grab a 4Suite-XML package and install that, then install the Amara package using the usual:</p>

<p>python setup.py install</p>

<p>Or a <a href="http://livingpyxml.python-hosting.com/wiki/AmaraWinInstallers">Windows installer</a>, or other method.</p>

<p>To report any problems, contribute, or just discuss Amara, please use the <a href="http://lists.fourthought.com/mailman/listinfo/4Suite">the 4Suite mailing list</a> for now. Just make sure you mention Amara in the subject line, preferably by prefixing with "[amara]".</p>

<h2>Downloads, etc.</h2>

<p>You can either grab what you need from the <a href="ftp://ftp.4suite.org/pub/Amara/">Amara FTP site</a>, or from the links below.  You can also use CVS (see farther below).</p>

<ul>
<li>
            <a href="http://notes.4suite.org/AmaraQuickRef">Quick reference, online</a>
          </li>
<li>
            <a href="/tech/4Suite/etc/amara-manual.html">User manual, online</a>
          </li>
<li>
            <a href="/tech/4Suite/etc/Amara-1.2a2.zip">Latest release (.zip)</a>
          </li>
<li>
            <a href="/tech/4Suite/etc/Amara-1.2a2.tar.gz">Latest release (.tar.gz)</a>
          </li>
<li>
            <a href="/tech/4Suite/etc/Amara-1.2a2.tar.bz2">Latest stand alone release (.tar.bz2)</a>
          </li>
<li>
            <a href="ftp://ftp.4suite.org/pub/cvs-snapshots/Amara-CVS.zip">Latest CVS snapshot (.zip)</a>
          </li>
<li>
            <a href="ftp://ftp.4suite.org/pub/cvs-snapshots/Amara-CVS.tar.gz">Latest CVS snapshot (.tar.gz)</a>
          </li>
<li>
            <a href="ftp://ftp.4suite.org/pub/cvs-snapshots/Amara-CVS.tar.bz2">Latest CVS snapshot (.tar.bz2)</a>
          </li>
<li>
            <a href="http://cvs.4suite.org/viewcvs/Amara/">browse CVS on-line</a>
          </li>
</ul>

<p>Windows users might want to start with Luis Miguel Morillas' nice page <a href="http://livingpyxml.python-hosting.com/wiki/InstallerForWindows">"Amara For Windows Installer"</a>.  There are links to other installation resources from the <a href="http://notes.4suite.org/AmaraXmlToolkit">wiki</a>.</p>

<p/>

<p/>

<p>There's a lot in Amara, but here are highlights:</p>

<h2>Amara Bindery: XML as easy as py</h2>

<p>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</p>

<pre>
          <code>&lt;monty&gt;
  &lt;python spam="eggs"&gt;What do you mean "bleh"&lt;/python&gt;
  &lt;python ministry="abuse"&gt;But I was looking for argument&lt;/python&gt;
&lt;/monty&gt;
</code>
        </pre>

<p>Becomes a data structure such that you can write:</p>

<pre>
          <code>binding.monty.python.spam
</code>
        </pre>

<p>In order to get the value "eggs" (as a Python Unicode object) or</p>

<pre>
          <code>binding.monty.python[1]
</code>
        </pre>

<p>In order to get the element object with the contents "But I was looking for argument".</p>

<p>There are other such tools for Python, and one thing that 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 is very efficient, using SAX to generate bindings. See the <a href="/tech/4Suite/etc/amara-manual.html">user documentation</a>.</p>

<h2>Scimitar: exceptional schema language for an exceptional programming language</h2>

<p>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.</p>

<p>First you run schema1.stron through the scimitar compiler script, scimitar.py:</p>

<pre>
          <code>scimitar.py schema1.sch
</code>
        </pre>

<p>A file, schema1.py (same file stem with the "py" extension sunstituted), is generated in the current working directory. If you'd prefer a different location or file name, use the "-o" option. The generated file is a validator script in Python. It checks the schematron rules specified in schema1.sch. You now run the generated validator script on each XML file you wish to validate:</p>

<pre>
          <code>python schema1-stron.py instance1.xml
</code>
        </pre>

<p>The validation report is generated on standard output by default, or you can use the "-o" option to redirect it to a file.</p>

<p>The validation report is an XML external parsed entity, a format much like
a well-formed XML document, but with some restrictions relaxed.</p>

<h2>Amara DOM Tools: giving DOM a more Pythonic face</h2>

<p>Amara DOM Tools features pushdom, similar to xml.dom.pulldom, but easier
to use, and a function to return an XPath location for any DOM node.</p>

<h2>Amara SAX Tools: SAX without the brain explosion</h2>

<p>Tenorsax (amara.saxtools.tenorsax) is a framework for "linerarizing" SAX logic so that it flows a bit more naturally, and needs a lot less state machine wizardry.</p>

<p/>

<h2>Getting the latest CVS version</h2>

<p>If you want to check on a new feature or bug fix recently checked in before there has been a full release, grabbing Amara from CVS is probably your best bet.</p>

<p>First of all, if you do not have a compatible 4Suite build installed, follow the instructions for getting and installing <a href="http://4suite.org/docs/4SuiteCVS.xml">4Suite CVS</a>.</p>

<p>Then to get Amara, log in for CVS operations and then pull the package:</p>

<pre>
          <code>cvs -d:pserver:anonymous@cvs.4suite.org:/var/local/cvsroot login
cvs -d:pserver:anonymous@cvs.4suite.org:/var/local/cvsroot get Amara
</code>
        </pre>

<p>Then build as usual, by running:</p>

<pre>
          <code>python setup.py install
</code>
        </pre>

<h2>Amara resources</h2>

<ul>
<li>
            <a href="http://lists.fourthought.com/pipermail/4suite/2005-March/007150.html">Jason Gaudette</a>'s notes on using <a href="http://www.py2exe.org/">Py2Exe</a> with Amara.</li>
<li>Amara intro in Spanish: <a href="http://livingpyxml.python-hosting.com/wiki/ArticuloCesarCardenas">"Procesamiento fácil de XML con Python y Amara"</a>
          </li>
</ul>

<h2>Others on Amara</h2>

<ul>
<li>
            <p>Ron Bourret: "<a href="http://www.rpbourret.com/xml/XMLDataBinding.htm#runtime">XML Data Binding Resources</a>"</p>
          </li>
<li>
            <p>
              <a href="http://groups.google.com/group/turbogears/browse_frm/thread/c79474f728b0958a/8b29d458a3815325?hl=en#8b29d458a3815325">"paron"</a>: "Amara is terrific -- easy to use, easy to learn."</p>
          </li>
<li>
            <p>Michael Williams: <a href="http://mail.python.org/pipermail/python-list/2006-January/322470.html">"I would recommend using Amara. It works wonders with XML."</a>
            </p>
          </li>
<li>
            <p>
              <a href="http://kofno.blogspot.com/2005/08/amara-xml-toolkit.html">"Kofno"</a>: "This tool handles XML exactly the way I think it should be handled. It's marvelous."</p>
          </li>
<li>
            <p>
              <a href="http://lists.fourthought.com/pipermail/4suite/2005-March/007150.html">Jason Gaudette</a>: "Amara is the best tool I've found so far for quick XML processing (and I've probably looked at a dozen by this point).  It's a pleasure to use.  If I had your mailing address, I'd have my wife send you some homemade cookies..."</p>
          </li>
<li>
            <p>
              <a href="http://www.livejournal.com/users/darthmdh/66117.html">Matthew Hawkins</a>: "I forgot to mention a week or so ago, if you're doing any XML work in Python, get Amara."  <a href="http://keithdevens.com/weblog/archive/2005/Aug/10/Amara#comment8148">He also wrote</a>: "Goodbye ugly, crud-filled SAX/DOM parsers, hello Amara! This is a fantastic toolset; very highly recommended.  Refactoring a small library script I have to use amara culled 2k worth of (now dead) code and also made it much more readable."</p>
          </li>
<li>
            <p>
              <a href="http://www.thescoop.org/archives/2005/04/29/xml-parsing-with-python/">Derek Willis</a>: " If I have to parse XML into a relational database, Amara is my tool of choice.... Nice and easy - the way everybody says XML should be."</p>
          </li>
<li>
            <p>
              <a href="http://lists.fourthought.com/pipermail/4suite/2005-April/013607.html">Tom Lazar:</a>: "i just wanted to chime in that just yesterday I had an urgent, real- world problem in where I needed to manipulate an XML Document programmatically...using Amara i hacked a python script that did the whole job in (literally) ten minutes. as I started the script I was a bit apprehensive: afterall our script would pick out certain nodes and assign new values to them (or delete them, depending) and then write it back to the file - but it all worked without a hitch. and looking at the script, you'd never think it was handling XML at all ;-)" <br/>
<a href="https://zope1.tomster.org/tomster/site/blog/archive/2005/08/10/uche">Tom also says</a> "I've been using Amara for several months now and except for some initial hickups in the early beta phase (which he cleared away at an impressive speed) it's been rock-solid for me ever since (I use the tools I wrote with Amara on a daily basis)."</p>
          </li>
<li>
            <p>"I just ran across your Amara toolkit, and have to say, I am quite impressed! This is by far one of the best open source python projects that I have come across to date. :o)" -- Shannon Johnson</p>
          </li>
<li>
            <p>"<a href="http://mail.python.org/pipermail/python-list/2005-March/271605.html">Amara rules xml to python conversions. I've used it successfully for an xml interface to legacy databases.</a>"</p>
          </li>
<li>
            <p>
              <a href="http://advogato.org/person/vdv/">Eric van der Vlist</a> ("...if you're using something like uche's [Amara Bindery] you may find XML configuration files easier to parse than native files formats."). Note: Eric is author of a similar tool to Amara Bindery, described in "<a href="http://dyomedea.com/papers/2004-OSCON/xmlDataDrivenClasses.pdf">Data-driven classes for Python</a>"</p>
          </li>
<li>
            <p>"<a href="http://keithdevens.com/weblog/archive/2003/Aug/05/Anobind-XML-API">Kieth Devens: Yet another XML API (for Python)</a>" [dates from Anobind days].</p>
          </li>
<li>
            <p>"<a href="http://www.amber.org/~petrilli/archive/2003/08/05/converting_xml_to_something_useful.html">Pensieri di un lunatico minore: Converting XML to something useful</a> [dates from Anobind days]"</p>
          </li>
<li>
            <p>
              <a href="http://livingpyxml.python-hosting.com/wiki/ArticuloCesarCardenas">César Cárdenas Desales</a>: "A pesar de que la libreria estándar Python cuenta con herramientas y modulos para el procesamiento de XML con SAX y DOM, muchos programadores han pensado que podrían existir formas más simples de trabajar con XML. Amara es un conjunto de herramientas que sirven para facilitar el procesamiento de XML usando Python."</p>
          </li>
</ul>

<p/>
</div>
    </div>
  </body>
</html>