Package net.sf.saxon.trans
Class CompilerInfo
java.lang.Object
net.sf.saxon.trans.CompilerInfo
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
ConstructorsConstructorDescriptionCompilerInfo(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
Modifier and TypeMethodDescriptionvoidClear the values of all stylesheet parameters that have been set using thesetParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)method.voidcopyFrom(CompilerInfo info) Copy all properties from a supplied CompilerInfoGet the registered CodeInjector, if anyGet the name of the default collationGet the default initial mode name for a stylesheet compiled using this CompilerInfo.Get the default initial template name for a stylesheet compiled using this CompilerInfo.Get the ErrorListener being used during this compilation episodeGet any function library that was previously set usingsetExtensionFunctionLibrary(net.sf.saxon.functions.FunctionLibrary).Get the name of the class that will be instantiated to create a MessageEmitter, to process the output of xsl:message instructions in XSLT.Get the optimizer options being used for compiling queries that use this static context.Get the OutputURIResolver that will be used to resolve URIs used in the href attribute of the xsl:result-document instruction.Get the package library to be used during the compilation episode.Get the values of all stylesheet parameters that have been set using thesetParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)method.intGet the policy for handling recoverable errors.Get the target edition under which the stylesheet will be executed.Get the URI Resolver being used in this compilation episode.intDeprecated.since 9.8 (always returns 30)booleanAsk whether assertions (xsl:assert instructions) should be enabled.booleanDetermine whether trace hooks are included in the compiled code.booleanAsk whether bytecode is to be generated in the compiled code.booleanAsk whether just-in-time compilation of template rules is in use for this XSLT compilationbooleanAsk whether any package produced by this compiler can be deployed to a different location, with a different base URIbooleanAsk whether schema-awareness has been requested by means of a call onsetSchemaAware(boolean)booleanDeprecated.since 9.8.0.2.voidsetAssertionsEnabled(boolean enabled) Say whether assertions (xsl:assert instructions) should be enabled.voidsetCodeInjector(CodeInjector injector) Set whether trace hooks are to be included in the compiled code.voidsetDefaultCollation(String collation) Set the name of the default collationvoidsetDefaultInitialMode(StructuredQName initialMode) Set the default initial mode name for a stylesheet compiled using this CompilerInfo.voidsetDefaultInitialTemplate(StructuredQName initialTemplate) Set the default initial template name for a stylesheet compiled using this CompilerInfo.voidsetErrorListener(ErrorListener listener) Set the ErrorListener to be used during this compilation episodevoidDeprecated.since 9.7.voidsetGenerateByteCode(boolean option) Set whether bytecode should be generated for the compiled stylesheet.voidsetJustInTimeCompilation(boolean jit) Say whether just-in-time compilation of template rules should be used for this XSLT compilationvoidsetMessageReceiverClassName(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.voidsetOptimizerOptions(OptimizerOptions options) Set the optimizer options to be used for compiling queries that use this static context.voidsetOutputURIResolver(OutputURIResolver outputURIResolver) Set the OutputURIResolver that will be used to resolve URIs used in the href attribute of the xsl:result-document instruction.voidsetPackageLibrary(PackageLibrary library) Set the package library to be used during the compilation episode.voidsetParameter(StructuredQName name, GroundedValue<?> seq) Set the value of a stylesheet parameter.voidsetRecoveryPolicy(int policy) Set the policy for handling recoverable errrors.voidsetRelocatable(boolean relocatable) Say whether any package produced by this compiler can be deployed to a different location, with a different base URIvoidsetSchemaAware(boolean schemaAware) Say that the stylesheet must be compiled to be schema-aware, even if it contains no xsl:import-schema declarations.voidsetTargetEdition(String edition) Set the target edition under which the stylesheet will be executed.voidsetURIResolver(URIResolver resolver) Set the URI Resolver to be used in this compilation episode.voidsetVersionWarning(boolean warn) Deprecated.since 9.8.0.2.voidsetXQueryLibraries(Collection<QueryLibrary> libraries) voidsetXsltVersion(int version) Deprecated.since Saxon 9.8 (has no effect).
-
Constructor Details
-
CompilerInfo
Create an empty CompilerInfo object with default settings. (Note, this does not copy settings from the defaultXsltCompilerInfo held by the configuration. For that, usenew CompilerInfo(config.getDefaultXsltCompilerInfo()). -
CompilerInfo
Create a CompilerInfo object as a copy of another CompilerInfo object- Parameters:
info- the existing CompilerInfo object- Since:
- 9.2
-
-
Method Details
-
copyFrom
Copy all properties from a supplied CompilerInfo- Parameters:
info- the CompilerInfo to be copied
-
getConfiguration
-
setJustInTimeCompilation
public void setJustInTimeCompilation(boolean jit) Say whether just-in-time compilation of template rules should be used for this XSLT compilationThe same effect can be achieved by
setOptimizerOptions(OptimizerOptions)with the appropriate setting ofOptimizerOptions.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
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
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 parameterseq- the value of the stylesheet parameter
-
getParameters
Get the values of all stylesheet parameters that have been set using thesetParameter(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 thesetParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)method. -
setTargetEdition
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", "JS", or "JS2".- Since:
- 9.7.0.5. Experimental and subject to change.
-
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", "JS", or "JS2".
- 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
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
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
Set the optimizer options to be used for compiling queries that use this static context. By default the optimizer options set in theConfigurationare used.- Parameters:
options- the optimizer options to be used
-
getOptimizerOptions
Get the optimizer options being used for compiling queries that use this static context. By default the optimizer options set in theConfigurationare 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 ofOptimizerOptions.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
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
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
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
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
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
-
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
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
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
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
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
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
-
setRecoveryPolicy
public void setRecoveryPolicy(int policy) Set the policy for handling recoverable errrors. Note that for some errors the decision can be made at run-time, but for the "ambiguous template match" error, the decision is (since 9.2) fixed at compile time.- Parameters:
policy- the recovery policy to be used. The options areConfiguration.RECOVER_SILENTLY,Configuration.RECOVER_WITH_WARNINGS, orConfiguration.DO_NOT_RECOVER.- Since:
- 9.2
-
getRecoveryPolicy
public int getRecoveryPolicy()Get the policy for handling recoverable errors. Note that for some errors the decision can be made at run-time, but for the "ambiguous template match" error, the decision is (since 9.2) fixed at compile time.- Returns:
- the current policy.
- Since:
- 9.2
-
isVersionWarning
public boolean isVersionWarning()Deprecated.since 9.8.0.2. Always now returns false. See bug 3278.Ask whether a warning is to be output when the stylesheet version does not match the processor version. In the case of stylesheet version="1.0", the XSLT specification requires such a warning unless the user disables it.- Returns:
- true if these messages are to be output.
- Since:
- 9.2
-
setVersionWarning
public void setVersionWarning(boolean warn) Deprecated.since 9.8.0.2. The method no longer has any effect. See bug 3278.Say whether a warning is to be output when the stylesheet version does not match the processor version. In the case of stylesheet version="1.0", the XSLT specification requires such a warning unless the user disables it.- Parameters:
warn- true if these messages are to be output.- Since:
- 9.2
-
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 onsetSchemaAware(boolean)- Returns:
- true if schema-awareness has been requested
-
setDefaultInitialTemplate
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
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
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
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.
-
setExtensionFunctionLibrary
Deprecated.since 9.7. Any extension function library set using this mechanism will not be available if the package is saved and reloaded.Set a library of extension functions. The functions in this library will be available in all modules of the stylesheet. The function library will be searched after language-defined libraries (such as built-in functions, user-defined XQuery functions, and constructor functions) but before extension functions defined at the Configuration level.- Parameters:
library- the function library to be added (replacing any that has previously been set). May be null to clear a previously-set library- Since:
- 9.4
-
getExtensionFunctionLibrary
Get any function library that was previously set usingsetExtensionFunctionLibrary(net.sf.saxon.functions.FunctionLibrary).- Returns:
- the extension function library, or null if none has been set.
- Since:
- 9.4
-
setXQueryLibraries
-
getQueryLibraries
-