Package net.sf.saxon.trans

## Class CompilerInfo

- java.lang.Object
- - net.sf.saxon.trans.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 Summary

    Constructors
    Constructor | Description
    --- | ---
    `CompilerInfo​(Configuration config)` | Create an empty CompilerInfo object with default settings.
    `CompilerInfo​(CompilerInfo info)` | Create a CompilerInfo object as a copy of another CompilerInfo object

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `clearParameters()` | Clear the values of all stylesheet parameters that have been set using the `setParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)` method.
    `void` | `copyFrom​(CompilerInfo info)` | Copy all properties from a supplied CompilerInfo
    `CodeInjector` | `getCodeInjector()` | Get the registered CodeInjector, if any
    `Configuration` | `getConfiguration()` |
    `java.lang.String` | `getDefaultCollation()` | Get the name of the default collation
    `java.lang.String` | `getDefaultElementNamespace()` |
    `StructuredQName` | `getDefaultInitialMode()` | Get the default initial mode name for a stylesheet compiled using this CompilerInfo.
    `StructuredQName` | `getDefaultInitialTemplate()` | Get the default initial template name for a stylesheet compiled using this CompilerInfo.
    `javax.xml.transform.ErrorListener` | `getErrorListener()` | Deprecated. since 10.0 - use `getErrorReporter()`
    `ErrorReporter` | `getErrorReporter()` | Get the error reporter: that is, a used-supplied object that is to receive notification of static errors found in the stylesheet
    `java.lang.String` | `getMessageReceiverClassName()` | Get the name of the class that will be instantiated to create a MessageEmitter, to process the output of xsl:message instructions in XSLT.
    `OptimizerOptions` | `getOptimizerOptions()` | Get the optimizer options being used for compiling queries that use this static context.
    `OutputURIResolver` | `getOutputURIResolver()` | Get the OutputURIResolver that will be used to resolve URIs used in the href attribute of the xsl:result-document instruction.
    `PackageLibrary` | `getPackageLibrary()` | Get the package library to be used during the compilation episode.
    `GlobalParameterSet` | `getParameters()` | Get the values of all stylesheet parameters that have been set using the `setParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)` method.
    `java.util.Collection<QueryLibrary>` | `getQueryLibraries()` |
    `java.lang.String` | `getTargetEdition()` | Get the target edition under which the stylesheet will be executed.
    `UnprefixedElementMatchingPolicy` | `getUnprefixedElementMatchingPolicy()` |
    `javax.xml.transform.URIResolver` | `getURIResolver()` | Get the URI Resolver being used in this compilation episode.
    `int` | `getXsltVersion()` | Deprecated. since 9.8 (always returns 30)
    `boolean` | `isAssertionsEnabled()` | Ask whether assertions (xsl:assert instructions) should be enabled.
    `boolean` | `isCompileWithTracing()` | Determine whether trace hooks are included in the compiled code.
    `boolean` | `isGenerateByteCode()` | Ask whether bytecode is to be generated in the compiled code.
    `boolean` | `isJustInTimeCompilation()` | Ask whether just-in-time compilation of template rules is in use for this XSLT compilation
    `boolean` | `isRelocatable()` | Ask whether any package produced by this compiler can be deployed to a different location, with a different base URI
    `boolean` | `isSchemaAware()` | Ask whether schema-awareness has been requested by means of a call on `setSchemaAware(boolean)`
    `void` | `setAssertionsEnabled​(boolean enabled)` | Say whether assertions (xsl:assert instructions) should be enabled.
    `void` | `setCodeInjector​(CodeInjector injector)` | Set whether trace hooks are to be included in the compiled code.
    `void` | `setDefaultCollation​(java.lang.String collation)` | Set the name of the default collation
    `void` | `setDefaultElementNamespace​(java.lang.String defaultNamespaceForElementsAndTypes)` |
    `void` | `setDefaultInitialMode​(StructuredQName initialMode)` | Set the default initial mode name for a stylesheet compiled using this CompilerInfo.
    `void` | `setDefaultInitialTemplate​(StructuredQName initialTemplate)` | Set the default initial template name for a stylesheet compiled using this CompilerInfo.
    `void` | `setErrorListener​(javax.xml.transform.ErrorListener listener)` | Deprecated. since 10.0 - use `setErrorReporter(ErrorReporter)`
    `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
    `void` | `setGenerateByteCode​(boolean option)` | Set whether bytecode should be generated for the compiled stylesheet.
    `void` | `setJustInTimeCompilation​(boolean jit)` | Say whether just-in-time compilation of template rules should be used for this XSLT compilation
    `void` | `setMessageReceiverClassName​(java.lang.String messageReceiverClassName)` | Set the name of the class that will be instantiated to create a MessageEmitter, to process the output of xsl:message instructions in XSLT.
    `void` | `setOptimizerOptions​(OptimizerOptions options)` | Set the optimizer options to be used for compiling queries that use this static context.
    `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.
    `void` | `setPackageLibrary​(PackageLibrary library)` | Set the package library to be used during the compilation episode.
    `void` | `setParameter​(StructuredQName name, GroundedValue seq)` | Set the value of a stylesheet parameter.
    `void` | `setRelocatable​(boolean relocatable)` | Say whether any package produced by this compiler can be deployed to a different location, with a different base URI
    `void` | `setSchemaAware​(boolean schemaAware)` | Say that the stylesheet must be compiled to be schema-aware, even if it contains no xsl:import-schema declarations.
    `void` | `setTargetEdition​(java.lang.String edition)` | Set the target edition under which the stylesheet will be executed.
    `void` | `setUnprefixedElementMatchingPolicy​(UnprefixedElementMatchingPolicy unprefixedElementMatchingPolicy)` |
    `void` | `setURIResolver​(javax.xml.transform.URIResolver resolver)` | Set the URI Resolver to be used in this compilation episode.
    `void` | `setXQueryLibraries​(java.util.Collection<QueryLibrary> libraries)` |
    `void` | `setXsltVersion​(int version)` | Deprecated. since Saxon 9.8 (has no effect).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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

    - #### getConfiguration

          public Configuration getConfiguration()

    - #### 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

          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

    - #### 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

    - #### getParameters

          public GlobalParameterSet getParameters()

      Get the values of all stylesheet parameters that have been set using the `setParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)` method.
      Returns:
        the set of all parameters that have been set.

    - #### clearParameters

          public void clearParameters()

      Clear the values of all stylesheet parameters that have been set using the `setParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)` method.

    - #### 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".
      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".
      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

    - #### setGenerateByteCode

          public void setGenerateByteCode​(boolean option)

      Set whether bytecode should be generated for the compiled stylesheet. This option is available only with Saxon-EE. The default depends on the setting in the configuration at the time the XsltCompiler is instantiated, and by default is true for Saxon-EE.

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

      Parameters:
        `option` - true if bytecode is to be generated, false otherwise
      Since:
        9.6

    - #### isGenerateByteCode

          public boolean isGenerateByteCode()

      Ask whether bytecode is to be generated in the compiled code.
      Returns:
        true if bytecode is to be generated, false if not.
      Since:
        9.6

    - #### 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

    - #### 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

          public void setErrorListener​(javax.xml.transform.ErrorListener listener)

      Deprecated.
      since 10.0 - use `setErrorReporter(ErrorReporter)`
      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

          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.

    - #### getMessageReceiverClassName

          public java.lang.String getMessageReceiverClassName()

      Get the name of the class that will be instantiated to create a MessageEmitter, to process the output of xsl:message instructions in XSLT.
      Returns:
        the full class name of the message emitter class.
      Since:
        9.2

    - #### setMessageReceiverClassName

          public void setMessageReceiverClassName​(java.lang.String messageReceiverClassName)

      Set the name of the class that will be instantiated to create a MessageEmitter, to process the output of xsl:message instructions in XSLT.
      Parameters:
        `messageReceiverClassName` - the message emitter class. This must implement net.sf.saxon.event.Emitter.
      Since:
        9.2

    - #### 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)

      Deprecated.
      since Saxon 9.8 (has no effect).
      Set the version of XSLT to be supported by this processor. From Saxon 9.8 this has no effect; the processor will always be an XSLT 3.0 processor.
      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.

    - #### getXsltVersion

          public int getXsltVersion()

      Deprecated.
      since 9.8 (always returns 30)
      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.

    - #### getDefaultElementNamespace

          public java.lang.String getDefaultElementNamespace()

    - #### setDefaultElementNamespace

          public void setDefaultElementNamespace​(java.lang.String defaultNamespaceForElementsAndTypes)

    - #### getUnprefixedElementMatchingPolicy

          public UnprefixedElementMatchingPolicy getUnprefixedElementMatchingPolicy()

    - #### setUnprefixedElementMatchingPolicy

          public void setUnprefixedElementMatchingPolicy​(UnprefixedElementMatchingPolicy unprefixedElementMatchingPolicy)

    - #### setXQueryLibraries

          public void setXQueryLibraries​(java.util.Collection<QueryLibrary> libraries)

    - #### getQueryLibraries

          public java.util.Collection<QueryLibrary> getQueryLibraries()