Class CompilerInfo


  • public class CompilerInfo
    extends java.lang.Object
    This class exists to hold information associated with a specific XSLT compilation episode. In JAXP, the URIResolver and ErrorListener used during XSLT compilation are those defined in the TransformerFactory. The .NET API and the s9api API, however, allow finer granularity, and this class exists to support that.
    • Constructor Detail

      • CompilerInfo

        public CompilerInfo​(Configuration config)
        Create an empty CompilerInfo object with default settings. (Note, this does not copy settings from the defaultXsltCompilerInfo held by the configuration. For that, use new CompilerInfo(config.getDefaultXsltCompilerInfo()).
      • CompilerInfo

        public CompilerInfo​(CompilerInfo info)
        Create a CompilerInfo object as a copy of another CompilerInfo object
        Parameters:
        info - the existing CompilerInfo object
        Since:
        9.2
    • Method Detail

      • copyFrom

        public void copyFrom​(CompilerInfo info)
        Copy all properties from a supplied CompilerInfo
        Parameters:
        info - the CompilerInfo to be copied
      • setJustInTimeCompilation

        public void setJustInTimeCompilation​(boolean jit)
        Say whether just-in-time compilation of template rules should be used for this XSLT compilation

        The same effect can be achieved by setOptimizerOptions(OptimizerOptions) with the appropriate setting of OptimizerOptions.JIT.

        Parameters:
        jit - true if just-in-time compilation should be used. With this option, static errors in the stylesheet code may be reported only when a template rule is first executed
        Since:
        9.8
      • isJustInTimeCompilation

        public boolean isJustInTimeCompilation()
        Ask whether just-in-time compilation of template rules is in use for this XSLT compilation
        Returns:
        true if just-in-time compilation should be used. With this option, static errors in the stylesheet code may be reported only when a template rule is first executed
        Since:
        9.8
      • setURIResolver

        @Deprecated
        public void setURIResolver​(javax.xml.transform.URIResolver resolver)
        Set the URI Resolver to be used in this compilation episode.
        Parameters:
        resolver - The URIResolver to be used. This is used to dereference URIs encountered in constructs such as xsl:include, xsl:import, and xsl:import-schema.
        Since:
        8.7
      • setResourceResolver

        public void setResourceResolver​(ResourceResolver resolver)
        Set the resource Resolver to be used in this compilation episode.
        Parameters:
        resolver - The resource resolver to be used. This is used to dereference URIs encountered in constructs such as xsl:include, xsl:import, and xsl:import-schema.
        Since:
        8.7
      • setParameter

        public void setParameter​(StructuredQName name,
                                 GroundedValue seq)
        Set the value of a stylesheet parameter. Static (compile-time) parameters must be provided using this method on the XsltCompiler object, prior to stylesheet compilation. Non-static parameters may also be provided using this method if their values will not vary from one transformation to another. No error occurs at this stage if the parameter is unknown, or if the value is incorrect for the parameter. Setting a value for a parameter overwrites any previous value set for the same parameter.
        Parameters:
        name - the name of the stylesheet parameter
        seq - the value of the stylesheet parameter
      • setTargetEdition

        public void setTargetEdition​(java.lang.String edition)
        Set the target edition under which the stylesheet will be executed.
        Parameters:
        edition - the Saxon edition for the run-time environment. One of "EE", "PE", "HE", or "JS", "JS2", "JS3".
        Since:
        9.7.0.5. Experimental and subject to change.
      • getTargetEdition

        public java.lang.String getTargetEdition()
        Get the target edition under which the stylesheet will be executed.
        Returns:
        the Saxon edition for the run-time environment. One of "EE", "PE", "HE", or "JS", "JS2", "JS3".
        Since:
        9.7.0.5. Experimental and subject to change.
      • isRelocatable

        public boolean isRelocatable()
        Ask whether any package produced by this compiler can be deployed to a different location, with a different base URI
        Returns:
        if true then static-base-uri() represents the deployed location of the package, rather than its compile time location
      • setRelocatable

        public void setRelocatable​(boolean relocatable)
        Say whether any package produced by this compiler can be deployed to a different location, with a different base URI
        Parameters:
        relocatable - if true then static-base-uri() represents the deployed location of the package, rather than its compile time location
      • setPackageLibrary

        public void setPackageLibrary​(PackageLibrary library)
        Set the package library to be used during the compilation episode. Any packages referenced using xsl:use-package declarations during the stylesheet compilation must be found in this package library
        Parameters:
        library - the package library
      • getPackageLibrary

        public PackageLibrary getPackageLibrary()
        Get the package library to be used during the compilation episode. Any packages referenced using xsl:use-package declarations during the stylesheet compilation must be found in this package library
        Returns:
        the package library
      • isAssertionsEnabled

        public boolean isAssertionsEnabled()
        Ask whether assertions (xsl:assert instructions) should be enabled. By default they are disabled. If assertions are enabled at compile time, then by default they will also be enabled at run time; but they can be disabled at run time by specific request
        Returns:
        true if assertions are enabled at compile time
      • setAssertionsEnabled

        public void setAssertionsEnabled​(boolean enabled)
        Say whether assertions (xsl:assert instructions) should be enabled. By default they are disabled. If assertions are enabled at compile time, then by default they will also be enabled at run time; but they can be disabled at run time by specific request
        Parameters:
        enabled - true if assertions are enabled at compile time
      • setOptimizerOptions

        public void setOptimizerOptions​(OptimizerOptions options)
        Set the optimizer options to be used for compiling queries that use this static context. By default the optimizer options set in the Configuration are used.
        Parameters:
        options - the optimizer options to be used
      • getOptimizerOptions

        public OptimizerOptions getOptimizerOptions()
        Get the optimizer options being used for compiling queries that use this static context. By default the optimizer options set in the Configuration are used.
        Returns:
        the optimizer options being used
      • getURIResolver

        public javax.xml.transform.URIResolver getURIResolver()
        Get the URI Resolver being used in this compilation episode.
        Returns:
        resolver The URIResolver in use. This is used to dereference URIs encountered in constructs such as xsl:include, xsl:import, and xsl:import-schema.
        Since:
        8.7
      • getResourceResolver

        public ResourceResolver getResourceResolver()
        Get the ResourceResolver being used
        Returns:
        the current ResourceResolver. Defaults to null.
      • getOutputURIResolver

        public OutputURIResolver getOutputURIResolver()
        Get the OutputURIResolver that will be used to resolve URIs used in the href attribute of the xsl:result-document instruction.
        Returns:
        the OutputURIResolver. If none has been supplied explicitly, the default OutputURIResolver is returned.
        Since:
        9.2
      • setOutputURIResolver

        public void setOutputURIResolver​(OutputURIResolver outputURIResolver)
        Set the OutputURIResolver that will be used to resolve URIs used in the href attribute of the xsl:result-document instruction.
        Parameters:
        outputURIResolver - the OutputURIResolver to be used.
        Since:
        9.2
      • setErrorListener

        @Deprecated
        public void setErrorListener​(javax.xml.transform.ErrorListener listener)
        Deprecated.
        Set the ErrorListener to be used during this compilation episode
        Parameters:
        listener - The error listener to be used. This is notified of all errors detected during the compilation.
        Since:
        8.7
      • getErrorListener

        @Deprecated
        public javax.xml.transform.ErrorListener getErrorListener()
        Deprecated.
        since 10.0 - use getErrorReporter()
        Get the ErrorListener being used during this compilation episode
        Returns:
        listener The error listener in use. This is notified of all errors detected during the compilation.
        Since:
        8.7
      • setErrorReporter

        public void setErrorReporter​(ErrorReporter reporter)
        Set an error reporter: that is, a used-supplied object that is to receive notification of static errors found in the stylesheet
        Parameters:
        reporter - the object to be notified of static errors
      • getErrorReporter

        public ErrorReporter getErrorReporter()
        Get the error reporter: that is, a used-supplied object that is to receive notification of static errors found in the stylesheet
        Returns:
        the object to be notified of static errors. This may be the error reporter that was previously set using setErrorReporter(ErrorReporter), or it may be a system-allocated error reporter.
      • setDefaultCollation

        public void setDefaultCollation​(java.lang.String collation)
        Set the name of the default collation
        Parameters:
        collation - the name of the default collation (if the stylesheet doesn't specify otherwise)
        Since:
        9.6
      • getDefaultCollation

        public java.lang.String getDefaultCollation()
        Get the name of the default collation
        Returns:
        the default collation. If none has been specified at the level of this CompilerInfo, this defaults to the default collation defined in the Configuration, which in turn defaults to the Unicode codepoint collation
        Since:
        9.6
      • setCodeInjector

        public void setCodeInjector​(CodeInjector injector)
        Set whether trace hooks are to be included in the compiled code. To use tracing, it is necessary both to compile the code with trace hooks included, and to supply a TraceListener at run-time
        Parameters:
        injector - the code injector used to insert trace or debugging hooks, or null to clear any existing entry
        Since:
        9.4
      • getCodeInjector

        public CodeInjector getCodeInjector()
        Get the registered CodeInjector, if any
        Returns:
        the code injector used to insert trace or debugging hooks, or null if absent
      • isCompileWithTracing

        public boolean isCompileWithTracing()
        Determine whether trace hooks are included in the compiled code.
        Returns:
        true if trace hooks are included, false if not.
        Since:
        8.9
      • setSchemaAware

        public void setSchemaAware​(boolean schemaAware)
        Say that the stylesheet must be compiled to be schema-aware, even if it contains no xsl:import-schema declarations. Normally a stylesheet is treated as schema-aware only if it contains one or more xsl:import-schema declarations. If it is not schema-aware, then all input documents must be untyped, and validation of temporary trees is disallowed (though validation of the final result tree is permitted). Setting the argument to true means that schema-aware code will be compiled regardless.
        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
      • isSchemaAware

        public boolean isSchemaAware()
        Ask whether schema-awareness has been requested by means of a call on setSchemaAware(boolean)
        Returns:
        true if schema-awareness has been requested
      • setDefaultInitialTemplate

        public void setDefaultInitialTemplate​(StructuredQName initialTemplate)
        Set the default initial template name for a stylesheet compiled using this CompilerInfo. This is only a default; it can be overridden when the stylesheet is executed
        Parameters:
        initialTemplate - the name of the default initial template, or null if there is no default. No error occurs (until run-time) if the stylesheet does not contain a template with this name.
        Since:
        9.3
      • getDefaultInitialTemplate

        public StructuredQName getDefaultInitialTemplate()
        Get the default initial template name for a stylesheet compiled using this CompilerInfo. This is only a default; it can be overridden when the stylesheet is executed
        Returns:
        the name of the default initial template, or null if there is no default, as set using setDefaultInitialTemplate(net.sf.saxon.om.StructuredQName)
        Since:
        9.3
      • setDefaultInitialMode

        public void setDefaultInitialMode​(StructuredQName initialMode)
        Set the default initial mode name for a stylesheet compiled using this CompilerInfo. This is only a default; it can be overridden when the stylesheet is executed
        Parameters:
        initialMode - the name of the default initial mode, or null if there is no default. No error occurs (until run-time) if the stylesheet does not contain a mode with this name.
        Since:
        9.3
      • getDefaultInitialMode

        public StructuredQName getDefaultInitialMode()
        Get the default initial mode name for a stylesheet compiled using this CompilerInfo. This is only a default; it can be overridden when the stylesheet is executed
        Returns:
        the name of the default initial mode, or null if there is no default, as set using setDefaultInitialMode(net.sf.saxon.om.StructuredQName)
        Since:
        9.3
      • setXsltVersion

        public void setXsltVersion​(int version)
        Set the version of XSLT to be supported by this processor. From Saxon 9.8 this had no effect; the processor will always be an XSLT 3.0 processor. In Saxon 11 the value 40 was permitted to enable experimental XSLT 4.0 extensions.
        Parameters:
        version - The decimal version number times ten, for example 30 indicates XSLT 3.0.
        Since:
        9.3. Changed in 9.7 to take an integer rather than a decimal. Ignored from 9.8. Deprecated in Saxon 9.8 (has no effect). Reintroduced in 11 to support 40 = draft XSLT 4.0 specification.
      • getXsltVersion

        public int getXsltVersion()
        Get the version of XSLT requested for this compilation.
        Returns:
        30 (for XSLT 3.0)
        Since:
        9.3 Changed in 9.7 to take an integer rather than a decimal. Changed in 9.8 to return the value 30 unconditionally. Deprecated in 9.8 (because only 30 was supported). Reintroduced in 11 to support 40 = draft XSLT 4.0 specification.
      • getDefaultElementNamespace

        public NamespaceUri getDefaultElementNamespace()
      • setDefaultElementNamespace

        public void setDefaultElementNamespace​(NamespaceUri defaultNamespaceForElementsAndTypes)
      • setXQueryLibraries

        public void setXQueryLibraries​(java.lang.Iterable<QueryLibrary> libraries)
      • getQueryLibraries

        public java.lang.Iterable<QueryLibrary> getQueryLibraries()
      • importStubFunctionLibrary

        public void importStubFunctionLibrary​(javax.xml.transform.stream.StreamSource jsonSignatures)
                                       throws XPathException
        Import a set of stub functions (names and signatures) from a JSON file. These functions will be added to the static context of the stylesheet, but any attempt to call the functions will fail with a dynamic error. The main purpose is to allow SaxonJS stylesheets to be compiled that at run-time will invoke external Javascript functions available on the target platform; this option will therefore normally be used when compiling with -nogo. If compiling from the Transform command line, the stub library can be specified using the option -stublib:filename.
        Parameters:
        jsonSignatures - The file containing JSON signatures. The format is described at StubFunctionLibrary.
        Throws:
        XPathException - if the JSON file is invalid