Package net.sf.saxon.style
Class Compilation
java.lang.Object
net.sf.saxon.style.Compilation
Represents an XSLT compilation episode, compiling a single package.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCompilation
(Configuration config, CompilerInfo info) Create a compilation object ready to perform an XSLT compilation -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the values of all stylesheet parameters that have been set using thesetParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)
method; and decouple the parameters held by this Compilation from those defined in the originating CompilerInfocompilePackage
(Source source) Compile a stylesheet packagestatic PreparedStylesheet
compileSingletonPackage
(Configuration config, CompilerInfo compilerInfo, Source source) Static factory method: Compile an XSLT stylesheet consisting of a single packagevoid
declareStaticVariable
(StructuredQName name, GroundedValue value, NestedIntegerValue precedence, boolean isParam) Declare a static variable.Get all mode names referenced anywhere in the stylesheet (including the unnamed mode).Get the compilation options used by this compilationGet the Saxon Configuration used by this Compilationint
Get the number of errors reported so farGet the stack of include/imports, used to detect circularitiesGet information about the package that was compiled in the course of this CompilationGet the values of all stylesheet parameters that have been set using thesetParameter(net.sf.saxon.om.StructuredQName, net.sf.saxon.om.GroundedValue)
method.Get the (most recent) stylesheet package compiled using this CompilationGet the QNameParser for parsing QNames in this compilation Note that the namespaceResolver will be unitializedGet the value of a static variableGet the precedence of a static variablegetStyleNodeFactory
(boolean topLevel) Get the StyleNodeFactory used to build the stylesheet treeGet the map of stylesheet modules.boolean
Ask whether the package has encountered an xsl:result-document instructionboolean
Ask whether a non-streamable construct has been found, forcing the entire stylesheet to fall back to unstreamed processingboolean
Ask whether the package being compiled is a library packageboolean
Ask whether this is the compile-time phase of a just-in-time compilation, during which template rules are not fully processedboolean
Ask whether this compilation is schema-aware.void
Method called internally while compiling a package to register that an xsl:use-package declaration has been encountered.void
Report a compile time error.void
Report a compile time error.void
reportWarning
(String message, String errorCode, Location location) void
Report a compile time warning.void
satisfyPackageDependencies
(XSLPackage thisPackage) After the first phase of processing, we have gathered information about the xsl:use-package elements in the stylesheet.void
setCreatesSecondaryResultDocuments
(boolean createsSecondaryResultDocuments) Say whether the compilation has encountered an xsl:result-document instructionvoid
void
setFallbackToNonStreaming
(boolean fallbackToNonStreaming) This method is called when a non-streamable construct is found, and the configuration optionFeature.STREAMING_FALLBACK
has been set; the effect is to mark the whole stylesheet as non-streamablevoid
setLibraryPackage
(boolean libraryPackage) Say whether the package being compiled is a library packagevoid
void
setPackageData
(PackageData pack) void
setParameter
(StructuredQName name, GroundedValue seq) Set the value of a stylesheet parameter.void
setPreScan
(boolean preScan) Say whether this is the compile-time phase of a just-in-time compilation, during which template rules are not fully processedvoid
setSchemaAware
(boolean schemaAware) Say that this compilation is schema-aware.void
setUsingPackages
(List<VersionedPackageName> users) Supply the name/version of the package that invoked this compilation by virtue of an xsl:use-package declaration, together with the users of that package, recursively.
-
Field Details
-
TIMING
public static boolean TIMING -
timer
-
-
Constructor Details
-
Compilation
Create a compilation object ready to perform an XSLT compilation- Parameters:
config
- the Saxon Configurationinfo
- compilation options
-
-
Method Details
-
compileSingletonPackage
public static PreparedStylesheet compileSingletonPackage(Configuration config, CompilerInfo compilerInfo, Source source) throws XPathException Static factory method: Compile an XSLT stylesheet consisting of a single package- Parameters:
config
- the Saxon ConfigurationcompilerInfo
- the compilation optionssource
- the source of the root stylesheet module in the package to be compiled. This may contain an xsl:package element at its root, or it may be a conventional xsl:stylesheet or xsl:transform, or a "simplified stylesheet" rooted at a literal result element- Returns:
- the PreparedStylesheet representing the result of the compilation
- Throws:
XPathException
- if any errors occur. The errors will have been reported to the ErrorListener contained in the CompilerInfo.
-
setUsingPackages
Supply the name/version of the package that invoked this compilation by virtue of an xsl:use-package declaration, together with the users of that package, recursively. The package is not allowed to use the packages in this list, because that would create a cycle of dependencies- Parameters:
users
- the packages that directly or indirectly use this package.
-
setPackageData
-
setMinimalPackageData
public void setMinimalPackageData() -
setExpectedNameAndVersion
-
registerPackageDependency
Method called internally while compiling a package to register that an xsl:use-package declaration has been encountered.- Parameters:
use
- details of the package dependency (name and version of the dependee package)
-
satisfyPackageDependencies
After the first phase of processing, we have gathered information about the xsl:use-package elements in the stylesheet. We now ensure that these dependencies are satisfied and are bound to actual loaded packages, invoking the compiler recursively to load the package if necessary. If there are cyclic references, these must be detected.- Parameters:
thisPackage
- the package being checked- Throws:
XPathException
- if errors are found
-
compilePackage
Compile a stylesheet package- Parameters:
source
- the XML document containing the top-level stylesheet module in the package, which may be an xsl:package element, an xsl:stylesheet or xsl:transform element, or a "simplified stylesheet" rooted at a literal result element- Returns:
- the StylesheetPackage representing the result of the compilation
- Throws:
XPathException
- if any error occurs while compiling the package
-
getConfiguration
Get the Saxon Configuration used by this Compilation- Returns:
- the Saxon Configuration
-
getCompilerInfo
Get the compilation options used by this compilation- Returns:
- the compilation options
-
getPackageData
Get information about the package that was compiled in the course of this Compilation- Returns:
- package information
-
isSchemaAware
public boolean isSchemaAware()Ask whether this compilation is schema-aware. It is schema-aware either if this is explicitly requested in the supplied CompilerInfo, or if this is explicitly requested within the stylesheet source code, for example by the presence of anxsl:import-schema
declaration or avalidation
attribute- Returns:
- true if the compilation is schema-aware
-
setSchemaAware
public void setSchemaAware(boolean schemaAware) Say that this compilation is schema-aware. This method is called internally during the course of a compilation if anxsl:import-schema
declaration is encountered.- Parameters:
schemaAware
- true if the compilation is schema-aware.
-
getStyleNodeFactory
Get the StyleNodeFactory used to build the stylesheet tree- Parameters:
topLevel
- true if the factory is for the top-level (package) module of a package- Returns:
- the StyleNodeFactory
-
getPrincipalStylesheetModule
Get the (most recent) stylesheet package compiled using this Compilation- Returns:
- the most recent stylesheet package compiled
-
reportError
Report a compile time error. This calls the errorListener to output details of the error, and increments an error count.- Parameters:
err
- the exception containing details of the error
-
reportError
Report a compile time error. This calls the errorListener to output details of the error, and increments an error count.- Parameters:
err
- the exception containing details of the error
-
getErrorCount
public int getErrorCount()Get the number of errors reported so far- Returns:
- the number of errors reported
-
reportWarning
Report a compile time warning. This calls the errorListener to output details of the warning.- Parameters:
err
- an exception holding details of the warning condition to be reported
-
reportWarning
-
declareStaticVariable
public void declareStaticVariable(StructuredQName name, GroundedValue value, NestedIntegerValue precedence, boolean isParam) throws XPathException Declare a static variable. This is called internally by the stylesheet compiler when a static variable declaration is encountered.- Parameters:
name
- the name of the variablevalue
- the value of the variableprecedence
- the import precedence in the form of a "decimal" value (e.g. 2.14.6)isParam
- true if this is an xsl:param rather than an xsl:variable- Throws:
XPathException
- if, for example, the value of the variable is incompatible with other variables having the same name
-
getStaticVariable
Get the value of a static variable- Parameters:
name
- the name of the required variable- Returns:
- the value of the variable if there is one, or null if the variable is undeclared
-
getStaticVariablePrecedence
Get the precedence of a static variable- Parameters:
name
- the name of the required variable- Returns:
- the precedence of the variable if there is one, or null if the variable is undeclared
-
getStylesheetModules
Get the map of stylesheet modules. This includes an entry for every stylesheet module in the compilation; the key is the absolute URI, and the value is the corresponding document.- Returns:
- the map from absolute URIs to (documents containing) stylesheet modules
-
getImportStack
Get the stack of include/imports, used to detect circularities- Returns:
- the include/import stack
-
getQNameParser
Get the QNameParser for parsing QNames in this compilation Note that the namespaceResolver will be unitialized- Returns:
- the QNameParser
-
isPreScan
public boolean isPreScan()Ask whether this is the compile-time phase of a just-in-time compilation, during which template rules are not fully processed- Returns:
- true if just-in-time compilation is in force and this is the static processing phase in which code is not fully processed. Return false if just-in-time compilation is not in force, or if this is the run-time phase during which full static analysis and code generation takes place.
-
setPreScan
public void setPreScan(boolean preScan) Say whether this is the compile-time phase of a just-in-time compilation, during which template rules are not fully processed- Parameters:
preScan
- true if just-in-time compilation is in force and this is the static processing phase in which code is not fully processed. Set to false if just-in-time compilation is not in force, or if this is the run-time phase during which full static analysis and code generation takes place.
-
isCreatesSecondaryResultDocuments
public boolean isCreatesSecondaryResultDocuments()Ask whether the package has encountered an xsl:result-document instruction- Returns:
- true if the package contains an xsl:result-document instruction
-
setCreatesSecondaryResultDocuments
public void setCreatesSecondaryResultDocuments(boolean createsSecondaryResultDocuments) Say whether the compilation has encountered an xsl:result-document instruction- Parameters:
createsSecondaryResultDocuments
- true if the package contains an xsl:result-document instruction
-
isLibraryPackage
public boolean isLibraryPackage()Ask whether the package being compiled is a library package- Returns:
- true if this is a library package
-
setLibraryPackage
public void setLibraryPackage(boolean libraryPackage) Say whether the package being compiled is a library package- Parameters:
libraryPackage
- if this is a library package
-
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; and decouple the parameters held by this Compilation from those defined in the originating CompilerInfo -
isFallbackToNonStreaming
public boolean isFallbackToNonStreaming()Ask whether a non-streamable construct has been found, forcing the entire stylesheet to fall back to unstreamed processing- Returns:
- true if the stylesheet must fall back to unstreamed processing
-
setFallbackToNonStreaming
public void setFallbackToNonStreaming(boolean fallbackToNonStreaming) This method is called when a non-streamable construct is found, and the configuration optionFeature.STREAMING_FALLBACK
has been set; the effect is to mark the whole stylesheet as non-streamable- Parameters:
fallbackToNonStreaming
- true if a construct has been found that is declared streamable but not actually streamable, if fallback processing was requested.
-
getAllKnownModeNames
Get all mode names referenced anywhere in the stylesheet (including the unnamed mode). This list is built up during the static use-when phase of processing. It is used to expandmode="#all"
appearing onxsl:template
.- Returns:
- the set of all mode names used.
-