SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
| Introduction
| Running XQuery from the Command Line
| Invoking XQuery from Java
| Calling XQuery Functions from Java
» | Result Format
| Extensibility
| Extensions
| Use Cases
Handling Source Documents
XML Schema Processing
The XPath API
Standards Conformance
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
XSLT Patterns

# 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.

Next