SocialTwist Tell-a-Friend

Comments --

Add

New Testertool – Anakia

Anakia is  an XML transformation tool,  that uses JDOM and Velocity to transform XML documents into the format of your choice.
It provides an alternative to using Ant’s task and XSL to process XML files.
The basic model that AnakiaTask uses is pretty straightforward :

Parse your XML into a JDOM Document:
SAXBuilder builder;
Document root =

Advertisment
My Twitter Friends
Friends: 939 Followers: 395
SocialTwist Tell-a-Friend

0

Comments

Add

New Testertool – Anakia

Anakia is  an XML transformation tool,  that uses JDOM and Velocity to transform XML documents into the format of your choice.

It provides an alternative to using Ant’s task and XSL to process XML files.

The basic model that AnakiaTask uses is pretty straightforward :

  1. Parse your XML into a JDOM Document:
    SAXBuilder builder;
    Document root = null;
    
    try
    {
        builder = new SAXBuilder(
            "org.apache.xerces.parsers.SAXParser" );
        root = builder.build( file );
    }
    catch( Exception )
    {
        System.out.println( ...  );
    }
  2. Stuff the Document (or root Element) into the context:
    context.put("root", root );
  3. Render a template using Velocity. Within the template, one can use JDOM’s methods to access the data contained in the XML document.

Anakia is potentially easier to learn than XSL, but it maintains a similar level of functionality. Learning cryptic <xsl:> tags is unnecessary; you only need to know how to use the provided Context objects, JDOM, and Velocity’s simple directives.

Anakia seems to perform much faster than Xalan’s XSL processor at creating pages. (23 pages are generated in 7-8 seconds on a PIII 500mhz running Win98 and JDK 1.3 with client Hotspot. A similar system using Ant’s <style> task took 14-15 seconds — nearly a 2x speed improvement.)

Anakia — intended to replace Stylebook, which was originally used to generate simple, static web sites in which all pages had the same look and feel — is great for documentation/project web sites, such as the sites on www.apache.org and jakarta.apache.org. As it is more targeted to a specific purpose, it does not provide some of XSL’s “extra” functionality.

The example in the jakarta-velocity/examples/anakia directory provides a good introduction to Anakia. You should find it quite simple to use.

Anakia creates a Context, which contains a JDOM Document object of the .xml page, as well as an (optional) JDOM Document object of your project.xml page. The .vsl page is executed (using Velocity) with the Context. You can then navigate your .xml file and pull information out of it by simply executing methods on the JDOM Document object.

Anakia is being used to create the documentation for not only this website, but also for the Jakarta Project’s website as well as many of the projects that live under the Jakarta Project. This process is documented on the site.

For more details visit here