net.sf.saxon.s9api
public class XsltCompiler extends Object
To construct an XsltCompiler, use the factory method Processor on the Processor object.
An XsltCompiler may be used repeatedly to compile multiple queries. Any changes made to the XsltCompiler (that is, to the static context) do not affect queries that have already been compiled. An XsltCompiler may be used concurrently in multiple threads, but it should not then be modified once initialized.
Since: 9.0
Constructor Summary | |
---|---|
protected | XsltCompiler(Processor processor)
Protected constructor. |
Method Summary | |
---|---|
XsltExecutable | compile(Source source)
Compile a stylesheet.
|
ErrorListener | getErrorListener()
Get the ErrorListener being used during this compilation episode |
URIResolver | getURIResolver()
Get the URIResolver to be used during stylesheet compilation.
|
boolean | isCompileWithTracing()
Ask whether trace hooks are included in the compiled code. |
boolean | isSchemaAware()
Ask whether schema-awareness has been requested by means of a call on
|
void | setCompileWithTracing(boolean option)
Set whether trace hooks are to be included in the compiled code. |
void | setErrorListener(ErrorListener listener)
Set the ErrorListener to be used during this compilation episode |
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 URIResolver to be used during stylesheet compilation. |
Parameters: processor the Saxon processor
Note: the term "compile" here indicates that the stylesheet is converted into an executable form. There is no implication that this involves code generation.
The source argument identifies the XML document holding the principal stylesheet module. Other modules will be located relative to this module by resolving against the base URI that is defined as the systemId property of the supplied Source.
The following kinds of javax.xml.transform.Source are recognized:
Parameters: source Source object representing the principal stylesheet module to be compiled
Returns: an XsltExecutable, which represents the compiled stylesheet.
Throws: SaxonApiException if the stylesheet contains static errors or if it cannot be read. Note that the exception that is thrown will not contain details of the actual errors found in the stylesheet. These will instead be notified to the registered ErrorListener. The default ErrorListener displays error messages on the standard error output.
Returns: listener The error listener in use. This is notified of all errors detected during the compilation. Returns null if no user-supplied ErrorListener has been set.
Returns: the URIResolver used during stylesheet compilation. Returns null if no user-supplied URIResolver has been set.
Returns: true if trace hooks are included, false if not.
Returns: true if schema-awareness has been requested
Since: 9.2
Parameters: option true if trace code is to be compiled in, false otherwise
Parameters: listener The error listener to be used. This is notified of all errors detected during the compilation.
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
This URIResolver is used to dereference the URIs appearing in xsl:import
,
xsl:include
, and xsl:import-schema
declarations.
It is not used at run-time for resolving requests to the document()
or similar functions.
Parameters: resolver the URIResolver to be used during stylesheet compilation.