Result Format

The result of a query is a sequence of nodes and atomic values - which means it is not, in general, an XML document. This raises the question as to how the results should be output.

The Saxon command line processor for XQuery by default produces the output in raw format. This converts the result sequence to a document following the rules of the XQuery document{} constructor, and then serializes this document.

The alternative is wrapped format, requested using the -wrap argument. This wraps the result sequence as an XML document, and then serializes the resulting document. Each item in the result sequence is wrapped in an element (such as result:element or result:atomic-value) according to its type. The sequence as a whole is wrapped in a result:sequence element.