Tamino SAX Example

I have downloaded the SAX example i.e TaminoAPI4J-sample.zip. I was able to run the sample example i.e the ProcessMessage.java. But I tried to run the same by changing it to my database which has
a specific schema . I tried to query it but I am getting the xml output in a wiered format. So Do I need to change the writeTo() method of Message.java ?? If so how should I change it to??
could anybody suggest any SAX example to insert and retrieve with more than one elements and attribuites in xml. Not the above example where in only one message in it though.

Here is my ProcessMessage.java

import com.softwareag.tamino.db.api.accessor.;
import com.softwareag.tamino.db.api.common.
import com.softwareag.tamino.db.api.connection.;
import com.softwareag.tamino.db.api.objectModel.
import com.softwareag.tamino.db.api.objectModel.sax.;
import com.softwareag.tamino.db.api.response.
import java.io.*;

public class ProcessMessage {

public ProcessMessage(String databaseURI,String collection) throws TConnectionException {
// Obtain the connection factory
TConnectionFactory connectionFactory = TConnectionFactory.getInstance();
// Obtain the connection to the database
connection = connectionFactory.newConnection( databaseURI );
// Instantiate the default handler that processes the sax events
messageDefaultHandler = new MessageDefaultHandler();
// Instantiate the document and element event handlers each of which delegates its events to the
// messageDefaultHandler
DocumentDefaultHandler docDefHandler = new DocumentDefaultHandler( messageDefaultHandler );
ElementDefaultHandler elDefHandler = new ElementDefaultHandler( messageDefaultHandler );
// Instantiate the specific TSAXObjectModel
TSAXObjectModel saxObjectModel = new TSAXObjectModel( “MessageSAXObjectModel” , Message.class , Message.class , docDefHandler , elDefHandler );
// Do the object model registration.
TXMLObjectModel.register( saxObjectModel );
// Obtain the concrete TXMLObjectAccessor with an underyling JDOM object model
accessor = connection.newXMLObjectAccessor( TAccessLocation.newInstance( collection ) , saxObjectModel );

private void performQuery(TQuery query) throws TException {
// Now lets make a query on the updated object
try {
TResponse response = accessor.query( query );
TXMLObjectIterator itr = response.getXMLObjectIterator();
FileOutputStream fos = null;
fos = new FileOutputStream(new File(“out.xml”));
TXMLObject txmlObj = (TXMLObject)itr.next();
catch(Exception e){
catch (TQueryException queryException) {
showAccessFailure( queryException );
throw queryException;
catch(Exception e){

// Show the reason for the access failure.
private void showAccessFailure(TAccessorException accessorException) {
// Obtain an access failure message telling the exact reason if Tamino request failed.
TAccessFailureMessage accessFailure = accessorException.getAccessFailureMessage();
if ( accessFailure != null )
System.out.println( “Access failed:” + accessFailure );
System.out.println( “Access failed:” + accessorException.getMessage() );

private void show() throws TException {
try {
//Hard coded the root element here so that I get all the document
TQuery query = TQuery.newInstance( “/log” );

performQuery( query );

catch (TException taminoException) {
finally {
// Close the connection.

public static void main(String[] args) throws TException {
// Change the database uri here to work with an appropiate one.
ProcessMessage processMessage = new ProcessMessage( DATABASE_URI , “service” );

// Constant for the database URI. Please edit to use your uri of interest.
private final static String DATABASE_URI = “http://localhost/tamino/edev”;

// The database connection.
private TConnection connection = null;

// The message default handler for all the sax events.
private MessageDefaultHandler messageDefaultHandler = null;

// The concrete accessor, here a high level TXMLObjectAccessor.
private TXMLObjectAccessor accessor = null;