Package net.sf.saxon.trans
Class CompilerInfo
java.lang.Object
net.sf.saxon.trans.CompilerInfo
- All Implemented Interfaces:
Serializable
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.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty CompilerInfo object with default settingsCompilerInfo
(CompilerInfo info) Create a CompilerInfo object as a copy of another CompilerInfo object -
Method Summary
Modifier and TypeMethodDescriptionGet the registered CodeInjector, if anyGet 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 OutputURIResolver that will be used to resolve URIs used in the href attribute of the xsl:result-document instruction.int
Get the policy for handling recoverable errors.Get the URI Resolver being used in this compilation episode.Get the version of XSLT supported by this processorboolean
Determine whether trace hooks are included in the compiled code.boolean
Ask whether schema-awareness has been requested by means of a call onsetSchemaAware(boolean)
boolean
Ask whether a warning is to be output when the stylesheet version does not match the processor version.void
setCodeInjector
(CodeInjector injector) Set whether trace hooks are to be included in the compiled code.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
(ErrorListener listener) Set the ErrorListener to be used during this compilation episodevoid
Set a library of extension functions.void
setMessageReceiverClassName
(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
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
setRecoveryPolicy
(int policy) Set the policy for handling recoverable errrors.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
setURIResolver
(URIResolver resolver) Set the URI Resolver to be used in this compilation episode.void
setVersionWarning
(boolean warn) Say whether a warning is to be output when the stylesheet version does not match the processor version.void
setXsltVersion
(DecimalValue version) Set the version of XSLT to be supported by this processor.
-
Constructor Details
-
CompilerInfo
public CompilerInfo()Create an empty CompilerInfo object with default settings -
CompilerInfo
Create a CompilerInfo object as a copy of another CompilerInfo object- Parameters:
info
- the existing CompilerInfo object- Since:
- 9.2
-
-
Method Details
-
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
-
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
-
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()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) 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
Set the version of XSLT to be supported by this processor. This determines the version of the XSLT specification to which the processor conforms. This does not have to match the version attribute in the stylesheet; for example if the processor version is 2.0 and the stylesheet is version 3.0, then the stylesheet will be processed using the rules for a 2.0 processor in forwards compatibility mode, rather than the rules for a 3.01 processor.The value 0.0 (which is the default) indicates that the processor version is to be taken from the version attribute of the xsl:stylesheet element.
XSLT 2.1 features are supported only in Saxon-EE. Setting the version to 3.0 here will not fail if the wrong edition is in use, but use of XSLT 3.0 features will fail subsequently.
- Parameters:
version
- must be numerically equal to 0.0, 2.0 or 3.0- Throws:
IllegalArgumentException
- if the version is invalid- Since:
- 9.3
-
getXsltVersion
Get the version of XSLT supported by this processor- Returns:
DecimalValue.TWO
orDecimalValue.THREE
, or zero indicating that the processor versino is taken from the version attribute of the xsl:stylesheet element.)- Since:
- 9.3
-
setExtensionFunctionLibrary
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
-