# Return types

The JAXP specification leaves it rather up to the implementation how the results of an XPath expression will be returned. This is partly because it is defined only for XPath 1.0, which has a much simpler type system, and partly because it is deliberately designed to be independent of the object model used to represent XML trees.

If you specify the return type `XPathConstants.BOOLEAN` then Saxon will return the effective boolean value of the expression, as a `java.lang.Boolean`. This is the same as wrapping the expression in a call of the XPath `boolean()` function.

If you specify the return type `XPathConstants.STRING` then Saxon will return the result of the expression converted to a string, as a `java.lang.String`. This is the same as wrapping the expression in a call of the XPath `string()` function.

If you specify the return type `XPathConstants.NUMBER` then Saxon will return the result of the expression converted to a double as a `java.lang.Double`. This is the same as wrapping the expression in a call of the XPath `number()` function.

If you specify the return type `XPathConstants.NODE` then Saxon will return the result the result as a node object in the selected object model. With the DOM model this will be an instance of `org.w3.dom.Node`, with the native Saxon model it will be an instance of `net.sf.saxon.om.NodeInfo`, and so on.

If the return type is `XPathConstants.NODESET`, the result will in general be a Java `List` containing node objects in the selected object model. It may also contain non-node objects if that's what the XPath expression returned. As a special case, if the supplied context node is a DOM node, and if the results are all DOM nodes, then they will be returned in the form of a DOM `NodeList` object.

Saxon does not recognize additional values for the return type other than the values defined in JAXP. If you want to return a different result type, for example a list of integers or a date, then it is probably best not to use this API; if you must, however, then use one of the methods in which the result type is unspecified. If any conversions are necessary, do them within the XPath expression itself, using casts or constructor functions. The Java object that is returned will be a representation of the XPath value, converted in the same way as arguments to a extension functions.

Next