retrieving a (random) XML document


So, here we go:
I would like to retrieve an arbitrary document from a known collection and a known doctype.
When I send the following XQuery to the database:

String querystring = “let $a:=input()/doctypename return count($a)”;

I received 250242. So I guess that means there are 250242 documents of that specific doctype.
Afterwards, I changed the XQuery expression to:

String querystring = “let $a:=input()/doctypename return $a”;

I didn’t get any result, it just didn’t terminate.
So I figured it is because of the size, so I didn’t use the usual
method but
accessor.xquery(query, 1);

Anyways, it was the same - no termination.

I thought that second method would just give me one result document?

How else could I do that?
Thanks for helping out!

Hi there,

Please try out with the below xquery, perhaps that is what you require -

declare namespace tf = ""
declare namespace ino=""
for $q in input()/ino:nonXML
where tf:getInoId($q) = 1
return $q

Rahul Roy

Tamino API for Java
Software AG (INDIA)

Hello dax42,

the expression “let $a:=input()/doctypename return $a” will assign all the documents of type “doctypename” to the variable $a, so returning “just one result” with a cursor will not help - the one result document contains all the “doctypename” documents!

I would follow a similar course to the one outlined by Rahul Roy: use a “for” rather than a “let”.

I hope that helps,