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

# Extensibility

The Saxon XQuery implementation allows you to call Java methods as external functions. The function does not need to be declared. Use a namespace declaration such as `declare namespace math=java:java.lang.Math`, and invoke the method as `math:sqrt(2)`.

More details of this mechanism are found in Writing Extension Functions; note however that for XQuery the only form of namespace URI accepted is `java:full.class.Name`.

Saxon recognizes the XQuery pragma syntax, but it currently defines only one pragma of its own, the `saxon:validate-type` pragma (see Extensions). Saxon will adopt the correct fallback behavior if presented with a query that uses another vendor's extensions, provided these are designed in conformance with the W3C pragma specification.

Saxon also recognizes the XQuery option declaration syntax. Several specific option declarations are provided: `declare option saxon:default` declares a default value for external variables (query parameters); `declare option saxon:output` declares a serialization parameter; and `declare option saxon:memo-function` defines whether the following function declaration is to be implemented as a memo function. These are described under Extensions. Any other option declaration in the Saxon namespace is ignored with a warning; an option declaration in any other namespace is ignored silently.

Next