First of all, thanks for a quick reply Trevor! 
I have just found new method “xquery”, I now have been trying to use it in properly way. Unfortunately, I could not achieve any success. 
My source code is (named ProcessPersonsDOM4JX.java):
--------------------------
import com.softwareag.tamino.db.API.objectModel.TXMLObject;
import com.softwareag.tamino.db.API.objectModel.TXMLObjectModel;
import com.softwareag.tamino.db.API.objectModel.dom4j.TDOM4JObjectModel;
import com.softwareag.tamino.db.API.objectModel.TXMLObjectIterator;
import com.softwareag.tamino.db.API.objectModel.TXMLObject;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import org.dom4j.QName;
import org.dom4j.Namespace;
import com.softwareag.tamino.db.API.accessor.TXMLObjectAccessor;
import com.softwareag.tamino.db.API.accessor.TAccessLocation;
import com.softwareag.tamino.db.API.accessor.TQuery;
import com.softwareag.tamino.db.API.accessor.TQueryException;
import com.softwareag.tamino.db.API.accessor.TInsertException;
import com.softwareag.tamino.db.API.accessor.TDeleteException;
import com.softwareag.tamino.db.API.accessor.TAccessorException;
import com.softwareag.tamino.db.API.accessor.TSystemAccessor;
import com.softwareag.tamino.db.API.accessor.TXQuery;
import com.softwareag.tamino.db.API.accessor.TXQueryException;
import com.softwareag.tamino.db.API.io.TStreamWriteException;
import com.softwareag.tamino.db.API.connection.TConnectionException;
import com.softwareag.tamino.db.API.connection.TConnectionFactory;
import com.softwareag.tamino.db.API.connection.TConnection;
import com.softwareag.tamino.db.API.response.TResponse;
import com.softwareag.tamino.db.API.common.*;
import java.util.Date;
import java.util.List;
import java.util.ListIterator;
import java.util.Iterator;
import java.text.SimpleDateFormat;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class ProcessPersonsDOM4JX {
protected static boolean checkServerAndPrintSystemInformation(TConnection Connection) throws TAccessorException {
TSystemAccessor SystemAccessor = Connection.newSystemAccessor();
if (!SystemAccessor.isServerAlive()) {
return false;
} else {
System.out.println( " server is alive" );
System.out.println( “\nHere is some systeminformation” );
System.out.println( “------------------------------\n” );
System.out.println( “The Tamino server hosting " + DATABASE_URI + " is version " + SystemAccessor.getServerVersion() );
System.out.println( “(Server API version: " + SystemAccessor.getServerAPIVersion() + “, Tamino API for Java version: " + SystemAccessor.getAPIVersion() + “)\n” );
return true;
}
}
// Helpermethod to get the text of a given tagname from a DOM4J tree
private static String getDOM4JElementTextByTagName(Element element, String tagname) {
List list = element.elements(tagname);
Element e = (Element)list.get(0);
return
e.node(0).getStringValue();
}
private static void printPerson(TXMLObject xmlObject) throws TStreamWriteException {
Element e = (Element)xmlObject.getElement();
String surname = getDOM4JElementTextByTagName(e, “surname”);
String firstname= getDOM4JElementTextByTagName(e, “firstname”);
String sex = getDOM4JElementTextByTagName(e, “sex”);
String city = getDOM4JElementTextByTagName(e, “city”);
String occupation = getDOM4JElementTextByTagName(e, “occupation”);
System.out.println( surname + “, " +
firstname +”, “+
sex +”, “+
city +”, “+
occupation);
System.out.print( " (” );
System.out.print( “ino:id="” + xmlObject.getId() +”" " );
System.out.print( “collection="” + xmlObject.getCollection() +”" " );
System.out.print( “doctype="” + xmlObject.getDoctype() +”" " );
System.out.println( “)” );
}
private static String performCountXQuery(TXMLObjectAccessor accessor, TXQuery query) throws TException {
try {
TXQuery countquery = TXQuery.newInstance( “count(” + query.getExpression() + “)” );
return accessor.xquery( countquery ).getQueryContentAsString();
}
catch (TXQueryException queryException) {
showAccessFailure( queryException );
throw queryException;
}
}
protected static void performXQueryAndListPersons(TXMLObjectAccessor accessor, TXQuery query) throws TException {
try {
TResponse response = accessor.xquery( query );
TXMLObjectIterator iterator = response.getXMLObjectIterator();
System.out.print( “The query "” + query + “" returns " );
if (!iterator.hasNext()) {
System.out.println( “no documents!” );
} else {
System.out.println( performCountXQuery( accessor, query ) + " documents, which are:” );
while (iterator.hasNext()) {
TXMLObject xmlObject = iterator.next();
System.out.print( " " );
printPerson(xmlObject);
}
}
} catch (TXQueryException queryException) {
showAccessFailure( queryException );
throw queryException;
}
}
private static void showAccessFailure(TAccessorException accessorException) {
TAccessFailureMessage accessFailure = accessorException.getAccessFailureMessage();
if ( accessFailure != null )
System.out.println( “Access failed with:” + accessFailure );
else
System.out.println( “Access failed:” + accessorException.getMessage() );
}
public static void main(String args) throws TException {
System.out.print( "Connecting to Tamino database " + DATABASE_URI + “, …” );
TConnectionFactory connectionFactory = TConnectionFactory.getInstance();
TConnection connection = connectionFactory.newConnection( DATABASE_URI );
if ( !checkServerAndPrintSystemInformation( connection ) )
return;
TXMLObjectModel dom4jObjectModel = TDOM4JObjectModel.getInstance();
TXMLObjectModel.register( dom4jObjectModel );
TXMLObjectAccessor accessor = connection.newXMLObjectAccessor( TAccessLocation.newInstance( COLLECTION ) , dom4jObjectModel );
try {
TXMLObject xmlObject = TXMLObject.newInstance( TDOM4JObjectModel.getInstance() );
TXQuery xqueryall = TXQuery.newInstance(XQUERY);
performXQueryAndListPersons( accessor, xqueryall );
}
catch (TException taminoException) {
taminoException.printStackTrace();
}
connection.close();
}
private final static String DATABASE_URI = “http://localhost/tamino/mydb”;
private final static String XQUERY = “for $b in input()/person return $b”;
private final static String COLLECTION = “people”;
}
--------------------------
After I executed this code I got:
-------------
Connecting to Tamino database http://localhost/tamino/mydb, … server is alive
Here is some systeminformation
------------------------------
The Tamino server hosting http://localhost/tamino/mydb is version 4.1.1.1
(Server API version: 4.1, Tamino API for Java version: 4.1.1.1)
The query “for $b in input()/person return $b” returns no documents!
-------------
However in Tamino Interactive Interface, when execute the following xquery
-------------
for $b in input()/person
return $b
-------------
I got records from mydb database Tamino. So in TII, xquery works!
How should I fix my source code to make it works?
Any help will be appreciated.
In advance, thanks a lot!
best regards,
Dariusz Baumann
#webMethods#Tamino#API-Management