TXMLObjectAccessor problem

TResponse response = accessor.xquery(TXQuery.newInstance(“for $a in input()/PortalLog return $a”),5);

TXMLObjectIterator obj = response.getXMLObjectIterator();
System.out.println("Here is ");
int count=0;



I am trying to figure out that why my count shows that the loop ran 999 times, when I have hard coded a value of 5 documents to return. Am I doing something wrong? or their is a problem with the accessor.xquery() method.


The quantity of 5 means that 5 documents will be returned each step. It allows a user to limit how many documents are returned each step of iteration in case of very large documents.

You would need to use a filter in your XQuery to limit how many documents are returned.

I just asked a similar question and the anser was that after 5 loops, the next() method will re-query the database for the next 5 records. Then after another 5 loops, it gets another 5 records, etc…

Hello All,

I have exactly the same problem as Shahid. I have the following code:

response = xmlObjectAccessor.xquery(xquery, 10);

and it returns all records in the database. Is there anything wrong in my code? Why does it return the whole content?

Thanks in advance,

Julien Martin.

Software AG Spain

The quantity value just limits the size of EACH response document. It is a way for a user to try to limit the size of EACH query response. It does NOT limit the total number of documents returned. All it does is limit the size of each packet returned.

If you wish to limit how many documents in TOTAL will be provided by the iterator then it is up to you to phrase the XQuery expression in such a way. I.e. just select documents that match a specific criteria.

What I am looking for is an equivalent of the LIMIT sql keyword that can be found in some relational database systems. Is there one in XQuery?
Thanks in advance,

Software AG Spain