net.sf.saxon.s9api
public class XQueryCompiler extends Object
To construct an XQueryCompiler, use the factory method Processor.
An XQueryCompiler may be used repeatedly to compile multiple queries. Any changes made to the XQueryCompiler (that is, to the static context) do not affect queries that have already been compiled. An XQueryCompiler may be used concurrently in multiple threads, but it should not then be modified once initialized.
Since: 9.0
Constructor Summary | |
---|---|
protected | XQueryCompiler(Processor processor)
Protected constructor |
Method Summary | |
---|---|
XQueryExecutable | compile(String query)
Compile a query supplied as a string.
|
XQueryExecutable | compile(File query)
Compile a query supplied as a file |
XQueryExecutable | compile(InputStream query)
Compile a query supplied as an InputStream
The base URI of the query should be supplied by calling setBaseURI |
XQueryExecutable | compile(Reader query)
Compile a query supplied as a Reader
The base URI of the query should be supplied by calling setBaseURI |
void | compileLibrary(String query)
Compile a library module supplied as a string. |
void | compileLibrary(File query)
Compile a library module supplied as a file. |
void | compileLibrary(Reader query)
Compile a library module supplied as a Reader. |
void | compileLibrary(InputStream query)
Compile a library module supplied as an InputStream. |
void | declareNamespace(String prefix, String uri)
Declare a namespace binding as part of the static context for queries compiled using this
XQueryCompiler. |
URI | getBaseURI()
Get the static base URI for the query |
String | getEncoding()
Get the encoding previously set for the supplied query. |
ErrorListener | getErrorListener()
Get the ErrorListener being used during this compilation episode |
String | getLanguageVersion()
Ask whether an XQuery 1.0 or XQuery 1.1 processor is being used |
ModuleURIResolver | getModuleURIResolver()
Get the user-defined ModuleURIResolver for resolving URIs used in import module
declarations in the XQuery prolog; returns null if none has been explicitly set either
here or in the Saxon Configuration. |
ItemType | getRequiredContextItemType()
Get the required type of the context item. |
StaticQueryContext | getUnderlyingStaticContext()
Get the underlying StaticQueryContext object that maintains the static context
information on behalf of this XQueryCompiler. |
boolean | isCompileWithTracing()
Ask whether trace hooks are included in the compiled code. |
boolean | isSchemaAware()
Ask whether schema-awareness has been requested either by means of a call on
|
boolean | isUpdatingEnabled()
Ask whether the query is allowed to use XQuery Update syntax |
void | setBaseURI(URI baseURI)
Set the static base URI for the query |
void | setCompileWithTracing(boolean option)
Set whether trace hooks are to be included in the compiled code. |
void | setEncoding(String encoding)
Set the encoding of the supplied query. |
void | setErrorListener(ErrorListener listener)
Set the ErrorListener to be used during this query compilation episode |
void | setLanguageVersion(String version)
Say whether an XQuery 1.0 or XQuery 1.1 processor is required. |
void | setModuleURIResolver(ModuleURIResolver resolver)
Set a user-defined ModuleURIResolver for resolving URIs used in import module
declarations in the XQuery prolog.
|
void | setRequiredContextItemType(ItemType type)
Declare the static type of the context item. |
void | setSchemaAware(boolean schemaAware)
Say that the query must be compiled to be schema-aware, even if it contains no
"import schema" declarations. |
void | setUpdatingEnabled(boolean updating)
Say whether the query is allowed to be updating. |
Parameters: processor the Saxon Processor
The base URI of the query should be supplied by calling setBaseURI
Parameters: query the text of the query
Returns: an XQueryExecutable representing the compiled query
Throws: SaxonApiException if the query compilation fails with a static error
Since: 9.0
Parameters: query the file containing the query. The URI corresponding to this file will be used as the base URI of the query, overriding any URI supplied using setBaseURI (but not overriding any base URI specified within the query prolog)
Returns: an XQueryExecutable representing the compiled query
Throws: SaxonApiException if the query compilation fails with a static error IOException if the file does not exist or cannot be read
Since: 9.1
The base URI of the query should be supplied by calling setBaseURI
Parameters: query the input stream on which the query is supplied. This will be consumed by this method
Returns: an XQueryExecutable representing the compiled query
Throws: SaxonApiException if the query compilation fails with a static error IOException if the file does not exist or cannot be read
Since: 9.1
The base URI of the query should be supplied by calling setBaseURI
Parameters: query the input stream on which the query is supplied. This will be consumed by this method
Returns: an XQueryExecutable representing the compiled query
Throws: SaxonApiException if the query compilation fails with a static error IOException if the file does not exist or cannot be read
Since: 9.1
The base URI of the query should be supplied by calling setBaseURI
Separate compilation of library modules is supported only under Saxon-EE
Parameters: query the text of the query
Throws: SaxonApiException if the query compilation fails with a static error
Since: 9.2
The encoding of the input stream may be specified using setEncoding
Separate compilation of library modules is supported only under Saxon-EE
Parameters: query the file containing the query. The URI corresponding to this file will be used as the base URI of the query, overriding any URI supplied using setBaseURI (but not overriding any base URI specified within the query prolog)
Throws: SaxonApiException if the query compilation fails with a static error IOException if the file does not exist or cannot be read
Since: 9.2
The base URI of the query should be supplied by calling setBaseURI
Separate compilation of library modules is supported only under Saxon-EE
Parameters: query the text of the query
Throws: SaxonApiException if the query compilation fails with a static error
Since: 9.2
The encoding of the input stream may be specified using setEncoding
The base URI of the query should be supplied by calling setBaseURI
Separate compilation of library modules is supported only under Saxon-EE
Parameters: query the text of the query
Throws: SaxonApiException if the query compilation fails with a static error
Since: 9.2
Parameters: prefix The namespace prefix. If the value is a zero-length string, this method sets the default namespace for elements and types. uri The namespace URI. It is possible to specify a zero-length string to "undeclare" a namespace; in this case the prefix will not be available for use, except in the case where the prefix is also a zero length string, in which case the absence of a prefix implies that the name is in no namespace.
Throws: NullPointerException if either the prefix or uri is null. IllegalArgumentException in the event of an invalid declaration of the XML namespace
Returns: the static base URI
Returns: the encoding previously set using setEncoding, or null if no value has been set. Note that this is not necessarily the actual encoding of the query.
Since: 9.2
Returns: listener The error listener in use. This is notified of all errors detected during the compilation. If no user-supplied ErrorListener has been set, returns the system-supplied ErrorListener.
Returns: version: "1.0" or "1.1"
Since: 9.2
import module
declarations in the XQuery prolog; returns null if none has been explicitly set either
here or in the Saxon Configuration.Returns: the registered ModuleURIResolver
Returns: the required type of the context item
Returns: the underlying StaticQueryContext object
Since: 9.2
Returns: true if trace hooks are included, false if not.
Returns: true if schema-awareness has been requested
Since: 9.2
Returns: true if the query is allowed to use the XQuery Update facility. Note that this does not necessarily mean that the query is an updating query; but if the value is false, the it must definitely be non-updating.
Since: 9.1
Parameters: baseURI the static base URI
Parameters: option true if trace code is to be compiled in, false otherwise
String
or as a Reader
. If no value
is set, the query processor will attempt to infer the encoding, defaulting to UTF-8 if no
information is available.Parameters: encoding the encoding of the supplied query, for example "iso-8859-1"
Since: 9.1
Parameters: listener The error listener to be used. This is notified of all errors detected during the compilation.
Parameters: version Must be "1.0" or "1.1". At present very limited support for XQuery 1.1 is available. This functionality is available only in Saxon-EE, and it cannot be used in conjunction with XQuery Updates. To use XQuery 1.1 features, the query prolog must also specify version="1.1".
Throws: IllegalArgumentException if the version is not 1.0 or 1.1.
Since: 9.2
import module
declarations in the XQuery prolog.
This will override any ModuleURIResolver that was specified as part of the configuration.Parameters: resolver the ModuleURIResolver to be used
Parameters: type the required type of the context item
Parameters: schemaAware If true, the stylesheet will be compiled with schema-awareness enabled even if it contains no xsl:import-schema declarations. If false, the stylesheet is treated as schema-aware only if it contains one or more xsl:import-schema declarations.
Since: 9.2
Parameters: updating true if the query is allowed to use the XQuery Update facility (requires Saxon-EE). If set to false, the query must not be an updating query. If set to true, it may be either an updating or a non-updating query.
Since: 9.1