Cannot obtain ino:id. How to debug?

Hi,

I am a newbiw in using Tamino. So pls bear with me if the question looks stupid.

I have written a java program to try retrieving records from Tamino,
but when printing out the value of the XMLObject, the ino:id (from xmlObject.getId()) is empty,
- but I can retrieve the other element values
- can view the ino:id value using the Tamino Explorer

Urgent help needed. Thanks.



The code segments are follow:
==========================================================================
package tra590;

import com.softwareag.tamino.db.api.accessor.TAccessLocation;
import com.softwareag.tamino.db.api.accessor.TXMLObjectAccessor;
import com.softwareag.tamino.db.api.accessor.TXQuery;
import com.softwareag.tamino.db.api.connection.TConnection;
import com.softwareag.tamino.db.api.connection.TConnectionFactory;
import com.softwareag.tamino.db.api.connection.TLocalTransaction;
import com.softwareag.tamino.db.api.objectModel.TXMLObject;
import com.softwareag.tamino.db.api.objectModel.dom.TDOMAdapter;
import com.softwareag.tamino.db.api.objectModel.dom.TDOMObjectModel;
import com.softwareag.tamino.db.api.response.TResponse;

import java.lang.reflect.Method;

public class TRA590Prototype {

private static String DB_CONNECTION_STR = “http://localhost/tamino/tra590”;
private static String COLLECTION = “carService”;
//CRUD operation constands
private static String CREATE = “create”;
private static String READ = “read”;
private static String UPDATE = “update”;
private static String DELETE = “delete”;
private static String XQUERY = “xquery”;


/
* prototype to test out tamino java api
* @param args
*/
public static void main(String[] args) {
TRA590Prototype prototype = new TRA590Prototype();

try {
prototype.test();
//prototype.testCreate();
//prototype.testXQueryUpdate();

} catch (Exception ex) {
ex.printStackTrace();
//prototype.processException(ex);
}
}

public void test() throws Exception {

String query = “for $q in input()/Car where $q/ownerID=495 return $q”;
TXQuery xquery = TXQuery.newInstance(query);
Object[] params = {COLLECTION, xquery};
TResponse response = (TResponse) execute(this.getClass().getName(), XQUERY, params);


System.out.println("==retrieving car info ");
TXMLObject xmlObject = response.getFirstXMLObject();

//////////////////////////////////////////////////////////////////// DOM

org.w3c.dom.Element domEle = null;
domEle = (org.w3c.dom.Element) xmlObject.getElement();

String nsURI = “http://namespaces.softwareag.com/tamino/response2”;
System.out.println(
“”
+ "\n ino id: " + xmlObject.getId()
+ "\n ino with ns: " + domEle.getAttributeNS(nsURI, “ino:id”)

+ “\n model:” + domEle.getElementsByTagName(“model”).item(0).getFirstChild().getNodeValue()
+ “\n variant:” + domEle.getElementsByTagName(“variant”).item(0).getFirstChild().getNodeValue()
+ “\n attribute chassisNumber:” + domEle.getAttribute(“chassisNumber”)
);

}

//@todo try update with attribute
public void testXQueryUpdate() throws Exception {
/String query = "update replace "
+ "input()/Customer/@customerID {‘28’}/lastName "
+ "with AAA ";
/

String query = "update replace "
+ "input()/Car[registrationNumber=‘M-5558-NX’]/ownerID "
+ “with 9999”;

TXQuery xquery = TXQuery.newInstance(query);
Object[] params = {COLLECTION, xquery};

execute(this.getClass().getName(), XQUERY, params);
}
private String getThisClassName() {
return this.getClass().getName();
}


/

* execute a method
* @param methodName
*/
protected Object execute(String className, String methodName, Object[] params)
throws Exception {
Method method = null;
Class[] paramTypes = null;
if (params != null) {
paramTypes = new Class[params.length];
for (int i = 0; i < params.length; i++) {
paramTypes[i] = params[i].getClass();
}
}
Class clazz = Class.forName(className);
try {
method = clazz.getMethod(methodName, paramTypes);
} catch (NoSuchMethodException nsme) {
System.out.println("methods not found : " + methodName);
}
return method.invoke(clazz.newInstance(), params);
}

protected TConnection getConnection(String connectionString) throws Exception {
TConnection connection = TConnectionFactory.getInstance().
newConnection(connectionString);
return connection;
}
protected void setTransaction(TConnection connection) throws Exception {
connection.useLocalTransactionMode();
}


public TResponse xquery(String collection, TXQuery xquery) throws Exception {
TConnection connection = getConnection(DB_CONNECTION_STR);
TLocalTransaction transaction = connection.useLocalTransactionMode();
TXMLObjectAccessor accessor = connection.newXMLObjectAccessor(
TAccessLocation.newInstance(collection),
TDOMObjectModel.getInstance());
TResponse response = accessor.xquery(xquery);
transaction.commit();
connection.close();
return response;
}
}
===========================================================================

There is nothing particularly wrong with your program. The problem is somewhere else. Your query:
String query = “for $q in input()/Car where $q/ownerID=495 return $q”;
is an XQuery query. Tamino does not return the ino:id in documents queried with an XQuery query. The XPlorer uses an X-Query query to retrive the document and in that case the ino:id is returned within the document.

So you have two options:
1. Use X-Query to retrieve the documents
2. Use XQuery and use the function tf:getInoId to retrieve the ino:id with the result.

Please check the Tamino XML Server online documentation for the differences between XQuery and X-Query and for the usage of the tf:getInoId function.

Thanks!