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 using the XQJ API
| Invoking XQuery from an application
| Calling XQuery Functions from Java
» | Result Format
| Compiling Queries to Java code
| Extensibility
| Extensions
| Use Cases
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# 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