Hi,
I am trying to build a java file to access Tamino, perform xquery and use objectModel.dom.TDOMObjectModel for a dom object model.
Here is my code:
String queryString = “declare namespace tf = "http://namespaces.softwareag.com/tamino/TaminoFunction\” declare namespace ino = "http://namespaces.softwareag.com/tamino/response2\" for $bib in input()/article return {$bib}"
// Initiate a xquery
TXQuery xquery = TXQuery.newInstance( queryString );
TResponse response = accessor.xquery( xquery );
TXMLObjectIterator iterator = response.getXMLObjectIterator();
while ( iterator.hasNext() ) {
TXMLObject xmlObject = iterator.next();
// Write the XML content to a StringWriter
StringWriter stringWriter = new StringWriter();
xmlObject.writeTo( stringWriter ); <=======()
//…
Object test = xmlObject.getDocument(); <=======(**)
if (test instanceof Document) {
Document doc = (Document) test;
//serialize doc…
}
}
From the code (),
One element of query results is returned at each loop iteration.
But from the code (),
returned documents are the same for every loop iteration, and that document includes all resulting elements enclosed by ino:response even though the code () is in the loop.
It is so strange to me. How can I convert each TXMLObject result to dom object model separately not as a merged form?
Please help me.
The xmlObject.getDocument() call return the entire xml document, i.e. the Tamino response document. You need to change this to xmlObject.getElement(). This returns a DOM Element object representing an individual document within the result set.
Hope this helps.
Stuart Fyffe-Collins
Software AG (UK) Ltd.