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

# 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 does not currently define any pragmas of its own. This means that 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. Two specific option declarations are provided: `declare option saxon:default` declares a default value for external variables (query parameters), and `declare option saxon:output` declares a serialization parameter. 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