|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.s9api.XQueryCompiler
public class XQueryCompiler
An XQueryCompiler object allows XQuery 1.0 queries to be compiled. The compiler holds information that represents the static context for the compilation.
To construct an XQueryCompiler, use the factory method Processor.newXQueryCompiler()
.
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.
Constructor Summary | |
---|---|
protected |
XQueryCompiler(Processor processor)
Protected constructor |
Method Summary | |
---|---|
XQueryExecutable |
compile(java.io.File query)
Compile a query supplied as a file |
XQueryExecutable |
compile(java.io.InputStream query)
Compile a query supplied as an InputStream |
XQueryExecutable |
compile(java.io.Reader query)
Compile a query supplied as a Reader |
XQueryExecutable |
compile(java.lang.String query)
Compile a query supplied as a string. |
void |
declareNamespace(java.lang.String prefix,
java.lang.String uri)
Declare a namespace binding as part of the static context for queries compiled using this XQueryCompiler. |
java.net.URI |
getBaseURI()
Get the static base URI for the query |
javax.xml.transform.ErrorListener |
getErrorListener()
Get the ErrorListener being used during this compilation episode |
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. |
boolean |
isCompileWithTracing()
Ask whether trace hooks are included in the compiled code. |
boolean |
isUpdatingEnabled()
Ask whether the query is allowed to use XQuery Update syntax |
void |
setBaseURI(java.net.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(java.lang.String encoding)
Set the encoding of the supplied query. |
void |
setErrorListener(javax.xml.transform.ErrorListener listener)
Set the ErrorListener to be used during this query compilation episode |
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 |
setUpdatingEnabled(boolean updating)
Say whether the query is allowed to be updating. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected XQueryCompiler(Processor processor)
processor
- the Saxon ProcessorMethod Detail |
---|
public void setBaseURI(java.net.URI baseURI)
baseURI
- the static base URIpublic java.net.URI getBaseURI()
public void setErrorListener(javax.xml.transform.ErrorListener listener)
listener
- The error listener to be used. This is notified of all errors detected during the
compilation.public javax.xml.transform.ErrorListener getErrorListener()
public void setCompileWithTracing(boolean option)
option
- true if trace code is to be compiled in, false otherwisepublic boolean isCompileWithTracing()
public void setModuleURIResolver(ModuleURIResolver resolver)
import module
declarations in the XQuery prolog.
This will override any ModuleURIResolver that was specified as part of the configuration.
resolver
- the ModuleURIResolver to be usedpublic ModuleURIResolver getModuleURIResolver()
import module
declarations in the XQuery prolog; returns null if none has been explicitly set either
here or in the Saxon Configuration.
public void setEncoding(java.lang.String encoding)
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.
encoding
- the encoding of the supplied query, for example "iso-8859-1"public void setUpdatingEnabled(boolean updating)
updating
- true if the query is allowed to use the XQuery Update facility
(requires Saxon-SA). 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.public boolean isUpdatingEnabled()
public void declareNamespace(java.lang.String prefix, java.lang.String uri)
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.
java.lang.NullPointerException
- if either the prefix or uri is null.
java.lang.IllegalArgumentException
- in the event of an invalid declaration of the XML namespacepublic void setRequiredContextItemType(ItemType type)
type
- the required type of the context itempublic ItemType getRequiredContextItemType()
public XQueryExecutable compile(java.lang.String query) throws SaxonApiException
The base URI of the query should be supplied by calling setBaseURI(java.net.URI)
query
- the text of the query
SaxonApiException
- if the query compilation fails with a static errorpublic XQueryExecutable compile(java.io.File query) throws SaxonApiException, java.io.IOException
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(java.net.URI)
(but not
overriding any base URI specified within the query prolog)
SaxonApiException
- if the query compilation fails with a static error
java.io.IOException
- if the file does not exist or cannot be readpublic XQueryExecutable compile(java.io.InputStream query) throws SaxonApiException, java.io.IOException
The base URI of the query should be supplied by calling setBaseURI(java.net.URI)
query
- the input stream on which the query is supplied. This will be consumed by this method
SaxonApiException
- if the query compilation fails with a static error
java.io.IOException
- if the file does not exist or cannot be readpublic XQueryExecutable compile(java.io.Reader query) throws SaxonApiException, java.io.IOException
The base URI of the query should be supplied by calling setBaseURI(java.net.URI)
query
- the input stream on which the query is supplied. This will be consumed by this method
SaxonApiException
- if the query compilation fails with a static error
java.io.IOException
- if the file does not exist or cannot be read
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |