problem with count returned value

Hi all,
how can i get the returned value of count function in my application?
I got the nullpointerException at the line

TResponse tresp=accessor.xquery ("count(for $q in input()/organisation return $q)") ;
String i=tresp.getQueryContentAsString();

the variable i has a value"xq:value/"
I have tested the xquery expression in x-plorer and got the right returned value.
I have no idea, why it doesn’t work in my application.

Thanks in advance,

Chacha

I have analysed the given xquery and the analysis is as follows:

      Fist of all, the given code lines doesn’t throw any exception.  Both code lines works fine.  The method getQueryContentAsString() works as :

“Gets the result of a query as a string, if available. Otherwise an empty string is returned. If the result is a set of XML nodes, the string contains the root element of each node without any children elements. Each root node is delivered with its attributes including the ino: attributes. If the result is a value or a set of values, the string returned is the concatenation of these values. In the special case, where the query results in a single value(e.g. count(*)), the string returned represents this value.”

If you want the returned value of the count function, then first retrieve the TXMLObject from TResponse. After getting TXMLObject, obtain the element using getElement() method. Then you can parse this element to get the required value.

Hi mj,
i followed your suggestion to get the value of the count function. It works well now.
But i don’t unterstand, why getQueryContentAsString() doesn’t return the value of count function as String. In my case the result of xquery is a single value, this implicits a String will be returned to represent this value. Explained as "In the special case, where the query results in a single value(e.g. count(*)), the string returned represents this value.”

Best Regards,

Chacha