# XQuery 1.0 Conformance

This release of Saxon implements the full XQuery 1.0 language as defined in the Recommendation of 23 January 2007. The restrictions noted with respect to XPath 2.0 apply equally to Saxon's support for XQuery 1.0.

XQuery conformance levels are described in Section 5 of the XQuery specification.

Saxon-B provides Minimal Conformance plus the following Optional Features:

- Full Axis Feature

- Module Feature

- Serialization Feature

Saxon-SA provides Minimal Conformance plus the following Optional Features:

- Schema Import Feature

- Schema Validation Feature

- Full Axis Feature

- Module Feature

- Serialization Feature

Neither Saxon product supports the Static Typing Feature, and there are no plans to do so.

There are some known non-conformances if the product is used in particular ways:

- In pull mode (-pull on the command line) there is a restriction that namespace undeclaration is not supported; this means that the query prolog option "copy-namespaces no-inherit" has no effect.

- Under .NET, when the `System.Xml` parser is used, attributes declared in the DTD as being of type `ID` are not accessible using the `id()` function. This is because the `System.Xml` parser does not make the DTD-defined attribute type available to the application.

- There are a number of limitations when queries are compiled to Java code.

Conformance Tests

Saxonica has submitted results for the published W3C XQuery Test suite. W3C has published have generated both summary and detail reports from the results; at the time of writing Saxon-SA is the only product to achieve a 100% pass rate.

The test driver used to measure these results is included in the Saxon distribution as part of the `saxon-resources-9.n` download.

Checklist of Implementation-Defined Items

Appendix D of the XQuery specification lists a number of features whose behavior is implementation-defined. For Saxon, the behavior is as follows:

1. The version of Unicode that is used to construct expressions.

   Saxon relies on the underlying Java or .NET I/O mechanisms to read the supplied query, so this is dependent on the underlying platform that is used to run Saxon.

2. The statically-known collations.

   Collation URIs of the form `http://saxon.sf.net/collation?param=value;param=value...` are always available: these map to the collations offered by the locales available within the Java VM in use. Additional collation URIs may be implemented by users and registered with the Saxon configuration via the Java API.

3. The implicit timezone.

   The implicit timezone is normally taken from the system clock. This may, however, be overridden via the Java API.

4. The circumstances in which warnings are raised, and the ways in which warnings are handled.

   Warnings are raised for a variety of conditions. Compile time warnings include:

   - Use of a path expression that can never select anything (for example `@a/@b`)

   - Use of an expression that can only succeed if one or more operands are empty sequences

   - Use of a string literal in a PITest that is not a valid NCName

   Warnings may also be raised at run-time, for example if the `collection()` function fails to load a document and recovery has been requested.

   Compile-time warnings are sent to the JAXP `ErrorListener` registered with the `Configuration`; the default `ErrorListener` displays them as messages on `System.err`. Run-time warnings are sent to the JAXP `ErrorListener` registered with the `Controller`; the default is the same.

5. The method by which errors are reported to the external processing environment.

   Compile-time errors are sent to the JAXP `ErrorListener` registered with the `Configuration`; the default `ErrorListener` displays them as messages on `System.err`. Run-time errors are sent to the JAXP `ErrorListener` registered with the `Controller`; the default is the same. When queries are invoked from a Java application, any error will also be notified by throwing an exception.

6. Whether the implementation is based on the rules of [XML 1.0] and [XML Names] or the rules of [XML 1.1] and [XML Names 1.1]. One of these sets of rules must be applied consistently by all aspects of the implementation.

   Saxon gives the user the choice: see Saxon and XML 1.1. Note that since Saxon allows the user to select which XML parser to use on a per-document basis, achievement of consistency across "all aspects of the implementation" is in part a user responsibility. Saxon will not reject any attempt to use an XML 1.1 parser in a 1.0 configuration, or vice versa.

   There are no known XML parsers available on the .NET 1.1 platform that support XML 1.1.

7. Any components of the static context or dynamic context that are overwritten or augmented by the implementation.

   The following table shows the components of the static context. For each component, the second column shows whether the component is overwritten or augmented by Saxon itself. The third columns shows whether it may be overwritten or augmented by an application, through facilities in the Java API.

   Component | Overritten or augmented by Saxon? | Can be set from Java API?
   XPath 1.0 Compatibility Mode | no | no
   Statically known namespaces | no | yes
   Default element/type namespace | no | yes
   Default function namespace | no | no
   In-scope schema types | yes: types corresponding to Java classes for use in extension functions | no
   In-scope element declarations | no | no
   In-scope attribute declarations | no | no
   In-scope variables | no | no
   Context item static type | no | no
   Function signatures | yes: any Java method on the classpath can be referenced | yes: there is a plug-in mechanism
   Statically known collations | yes: collations of the form http://saxon.sf.net/collation?params | yes
   Default collation | no | yes
   Construction mode | no | no
   Ordering mode | no | no
   Default order for empty sequences | no | no
   Boundary-space policy | no | no
   Copy-namespaces mode | no | no
   Base URI | yes: inferred from the location of the query | yes
   Statically known documents | no | no
   Statically known collections | no | no
   Statically known default collection type | no | no

   For the dynamic context, the corresponding settings are:

   Context item | no | yes
   Context position | no | no
   Context size | no | no
   Variable values | no | only for declared external variables
   Function implementations | no | yes (extension functions)
   Current dateTime | yes (from system clock) | yes
   Implicit timezone | yes (from system clock) | yes
   Available documents | yes (all documents reachable using Java URL connections) | yes (URIResolver)
   Available collections | no | yes (CollectionResolver/catalog)
   Default collection | no | yes (CollectionResolver/catalog)

8. Which of the optional axes are supported by the implementation, if the Full-Axis Feature is not supported.

   The Full-Axis features is supported.

9. The default handling of empty sequences returned by an ordering key (sortspec) in an order by clause (empty least or empty greatest).

   Empty least

10. The names and semantics of any extension expressions (pragmas) recognized by the implementation.

    Saxon-SA recognizes one pragma: `saxon:validate-type`. For details, see XQuery extensions.

11. The names and semantics of any option declarations recognized by the implementation.

    See XQuery Extensibility.

12. Protocols (if any) by which parameters can be passed to an external function, and the result of the function can be returned to the invoking query.

    Java methods can be called as Extension Functions

13. How the implementation handles location hints in module imports, if the Module Feature is supported.

    The location hint is interpreted as a relative URI, relative to the base URI of the referencing module. It is then dereferenced using the Java URL mechanisms, unless the user has nominated a `ModuleURIResolver`, in which case the interpretation is under user control.

14. Any static typing extensions supported by the implementation, if the Static Typing Feature is supported.

    Not applicable.

15. The means by which serialization is invoked, if the Serialization Feature is supported.

    Serialization may be invoked from the command line or from the Java or .NET API. Serialization parameters may be supplied on the command line, from the Java or .NET API, or through option declarations in the query prolog.

16. The default values for the byte-order-mark, encoding, media-type, normalization-form, omit-xml-declaration, standalone, and version parameters, if the Serialization Feature is supported.

    As specified in Appendix C.3 of the XQuery specification.

Next