I need to evaluate an xpath expression without knowing its return value in advance. I don't care about the distinction between a Node and a NodeSet, but I do care about NodeSet versus a String or a number.

For example, an xpath with a `sum` or `concat` function can return a number or a string (or boolean). An xpath with a regular xml path returns a nodeset, potentially with only one node.

How can I call the `XPathExpression.evaluate()` function (javadoc [here](http://download.oracle.com/javase/6/docs/api/javax/xml/xpath/XPathExpression.html#evaluate%28java.lang.Object,%20javax.xml.namespace.QName%29))? I don't know what QName to pass to it as the second parameter. The class `XPathConstants` contains the closed list of constants allowed (these are Node, NodeSet, String, Number and Boolean).

Is it possible to specify an "all" or "don't care" value and then inspect the returned object for its type?

I thought maybe to use the overloaded version of this function, which always return a String. However, I don't see how this will work if the xpath expression is meant to return a node set.