You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Chris Hitzke <ch...@adobe.com> on 2004/03/04 18:56:59 UTC

Anakia with JDOM and Velocity to transform XML document into HTML file

I am using Anakia along with JDOM and Velocity to transform my XML document 
into
HTML file. I am looking at the examples on the Apache web site. But, I have not
seen a clear cut example. Does anybody have a clear cut coding example 
(provide java code,xml file,
velocity template) of how to make this transformation within Java? Please, 
respond..... Thanks for the help....




documentation of Apache website...
=================================

Anakia uses JDOM and Velocity to transform XML documents into the format of 
your choice.

The basic model that AnakiaTask uses is pretty straightforward :
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( ...  );
}
Stuff the Document (or root Element) into the context:
context.put("root", root );
Render a template using Velocity. Within the template, one can use JDOM's 
methods to access the data contained in the XML document.


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org