Class StaticQueryContextEE


  • public class StaticQueryContextEE
    extends StaticQueryContextPE
    A version of StaticQueryContext for Saxon-EE, that extends the capability by allowing compilation of library modules.
    • Constructor Detail

      • StaticQueryContextEE

        public StaticQueryContextEE​(Configuration config)
        Create a StaticQueryContext using a given Configuration. This creates a StaticQueryContext for a main module (that is, a module that is not a library module). The StaticQueryContext is initialized from defaults held in the Configuration.
        Parameters:
        config - the Saxon Configuration
        Since:
        9.2
    • Method Detail

      • setSchemaAware

        public void setSchemaAware​(boolean aware)
        Say whether this query is schema-aware
        Overrides:
        setSchemaAware in class StaticQueryContext
        Parameters:
        aware - true if this query is schema-aware
        Since:
        9.2.1.2
      • isSchemaAware

        public boolean isSchemaAware()
        Ask whether this query is schema-aware
        Overrides:
        isSchemaAware in class StaticQueryContext
        Returns:
        true if this query is schema-aware
        Since:
        9.2.1.2
      • setStreaming

        public void setStreaming​(boolean option)
        Say whether the query should be compiled and evaluated to use streaming. This affects subsequent calls on the compile() methods. This option requires Saxon-EE.
        Overrides:
        setStreaming in class StaticQueryContext
        Parameters:
        option - if true, the compiler will attempt to compile a query to be capable of executing in streaming mode. If the query cannot be streamed, a compile-time exception is reported. In streaming mode, the source document is supplied as a stream, and no tree is built in memory. The default is false. Setting the value to true has the side-effect of setting the required context item type to "document node"; this is to ensure that expressions such as //BOOK are streamable.
        Since:
        9.6
      • isStreaming

        public boolean isStreaming()
        Ask whether the streaming option has been set, that is, whether subsequent calls on compile() will compile queries to be capable of executing in streaming mode.
        Overrides:
        isStreaming in class StaticQueryContext
        Returns:
        true if the streaming option has been set.
        Since:
        9.6
      • compileLibrary

        public void compileLibrary​(java.lang.String query)
                            throws XPathException
        Compile an XQuery library module for subsequent evaluation. The source text of the query is supplied as a String. The base URI of the query is taken from the static context, and defaults to the current working directory.

        Note that this interface makes the caller responsible for decoding the query and presenting it as a string of characters. This means it is likely that any encoding specified in the query prolog will be ignored.

        Overrides:
        compileLibrary in class StaticQueryContext
        Parameters:
        query - The XQuery library module to be compiled, supplied as a string.
        Throws:
        XPathException - if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared, or contains other static errors.
        Since:
        9.2 (changed in 9.3 to return void)
      • compileLibrary

        public void compileLibrary​(java.io.Reader source)
                            throws XPathException,
                                   java.io.IOException
        Prepare an XQuery library module for subsequent evaluation. The Query is supplied in the form of a Reader. The base URI of the query is taken from the static context, and defaults to the current working directory. The effect of the method is that subsequent query compilations using this static context can import the module URI without specifying a location hint; the import then takes effect without requiring the module to be compiled each time it is imported.

        Note that this interface makes the Reader responsible for decoding the query and presenting it as a stream of characters. This means it is likely that any encoding specified in the query prolog will be ignored. Also, some implementations of Reader cannot handle a byte order mark.

        Overrides:
        compileLibrary in class StaticQueryContext
        Parameters:
        source - A Reader giving access to the text of the XQuery query to be compiled.
        Throws:
        XPathException - if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared, or any other static error is reported.
        java.io.IOException - if a failure occurs reading the supplied input.
        Since:
        9.2 (changed in 9.3 to return void)
      • compileLibrary

        public void compileLibrary​(java.io.InputStream source,
                                   java.lang.String encoding)
                            throws XPathException,
                                   java.io.IOException
        Prepare an XQuery library module for subsequent evaluation. The Query is supplied in the form of a InputStream, with an optional encoding. If the encoding is not specified, the query parser attempts to obtain the encoding by inspecting the input stream: it looks specifically for a byte order mark, and for the encoding option in the version declaration of an XQuery prolog. The effect of the method is that subsequent query compilations using this static context can import the module URI without specifying a location hint; the import then takes effect without requiring the module to be compiled each time it is imported. The encoding defaults to UTF-8. The base URI of the query is taken from the static context, and defaults to the current working directory.
        Overrides:
        compileLibrary in class StaticQueryContext
        Parameters:
        source - An InputStream giving access to the text of the XQuery query to be compiled, as a stream of octets
        encoding - The encoding used to translate characters to octets in the query source. The parameter may be null: in this case the query parser attempts to infer the encoding by inspecting the source, and if that fails, it assumes UTF-8 encoding
        Throws:
        XPathException - if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared, or any other static error is reported.
        java.io.IOException - if a failure occurs reading the supplied input.
        Since:
        9.2 (changed in 9.3 to return void)
      • getCompiledLibrary

        public QueryLibrary getCompiledLibrary​(java.lang.String namespace)
        Get a previously compiled library module
        Overrides:
        getCompiledLibrary in class StaticQueryContext
        Parameters:
        namespace - the module namespace
        Returns:
        the QueryLibrary if a module with this namespace has been compiled as a library module; otherwise null.
        Since:
        9.3