Package net.sf.saxon.expr.instruct
Class Executable
java.lang.Object
net.sf.saxon.expr.instruct.Executable
- Direct Known Subclasses:
PreparedStylesheet
A compiled stylesheet or a query in executable form.
Note that the original stylesheet tree is not retained.
In the case of XSLT 3.0, the Executable represents the collection of all packages making up
a stylesheet; it is synthesized when the constituent packages are linked, and is not available
during compilation (because each package is compiled separately). For XSLT the Executable
will always be a
PreparedStylesheet
, which is a subclass.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExecutable
(Configuration config) Create a new Executable (a collection of stylesheet modules and/or query modules) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPackage
(PackageData data) Add information about a packagevoid
addQueryLibraryModule
(QueryModule module) Add an XQuery library module to the configuration.void
Add a name to the list of query module location hints that have been processed during the construction of this executablecheckInitialContextItem
(Item contextItem, XPathContext context) Check that the supplied global context item meets all requirements, and perform any required conversions or defaultingvoid
Check the supplied parameters.boolean
Ask whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documentsvoid
explainGlobalVariables
(ExpressionPresenter presenter) Explain (that is, output an expression tree) the global variablesvoid
fixupQueryModules
(QueryModule main) Fix up global variables and functions in all query modules.Get the index of named character mapsGet the configurationGet the library containing all the in-scope functions in the static contextGet the constraints on the initial global context itemGet the global parameter with a given name, if there is oneGet all the registered global parametersGet the host languageGet the properties for xsl:output.Get a named output formatGet information about the packages in this executableGet the primary output properties, that is, the output properties for the primary result destination.Get an iterator over all the query library modules (does not include the main module)getQueryLibraryModules
(NamespaceUri namespace) Locate the known XQuery library modules for a given module namespace.getQueryModuleWithSystemId
(String systemId, QueryModule topModule) Get the query library module with a given systemIDboolean
Ask whether a query module location hint has already been processedboolean
Ask whether this executable is schema-aware, that is, whether the query or transformation imports a schema.void
Register a global parametervoid
Set the index of named character mapsvoid
setConfiguration
(Configuration config) Set the configurationvoid
setCreatesSecondaryResult
(boolean flag) Set whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documentsvoid
setDefaultOutputProperties
(Properties properties) Set the default output properties (the properties for the unnamed output format)void
setFunctionLibrary
(FunctionLibraryList functionLibrary) Set the library containing all the in-scope functions in the static contextvoid
setGlobalContextRequirement
(GlobalContextRequirement requirement) Set the accumulators declared on xsl:global-context-itemvoid
setHostLanguage
(HostLanguage language) Set the host languagevoid
setOutputProperties
(StructuredQName qName, Properties properties) Add a named output formatvoid
setSchemaAware
(boolean aware) Set whether this executable is schema-aware.void
setTopLevelPackage
(PackageData topLevelPackage)
-
Field Details
-
schemaAware
protected boolean schemaAware
-
-
Constructor Details
-
Executable
Create a new Executable (a collection of stylesheet modules and/or query modules)- Parameters:
config
- the Saxon Configuration
-
-
Method Details
-
setConfiguration
Set the configuration- Parameters:
config
- the Configuration
-
getConfiguration
Get the configuration- Returns:
- the Configuration
-
getTopLevelPackage
-
setTopLevelPackage
-
addPackage
Add information about a package- Parameters:
data
- information about a package
-
getPackages
Get information about the packages in this executable- Returns:
- a list of packages
-
setHostLanguage
Set the host language- Parameters:
language
- the host language, as a constant such asHostLanguage.XSLT
orHostLanguage.XQUERY
-
getHostLanguage
Get the host language- Returns:
- a value identifying the host language:
HostLanguage.XQUERY
orHostLanguage.XSLT
-
getFunctionLibrary
Get the library containing all the in-scope functions in the static context- Returns:
- the function libary
-
setFunctionLibrary
Set the library containing all the in-scope functions in the static context- Parameters:
functionLibrary
- the function libary
-
setCharacterMapIndex
Set the index of named character maps- Parameters:
cmi
- a hash table that maps the names of character maps to the HashMap objects representing the character maps
-
getCharacterMapIndex
Get the index of named character maps- Returns:
- the hash table that maps the names of character maps to the IntHashMap objects representing the character maps
-
setDefaultOutputProperties
Set the default output properties (the properties for the unnamed output format)- Parameters:
properties
- the output properties to be used when the unnamed output format is selected
-
getPrimarySerializationProperties
Get the primary output properties, that is, the output properties for the primary result destination. In XSLT these are the properties defined on unnamedxsl:output
declarations in the top-level stylesheet package; in XQuery they are the properties defined using"declare option output:x = 'value'"
.- Returns:
- the properties for the unnamed output format
-
setOutputProperties
Add a named output format- Parameters:
qName
- the structured QName of the output formatproperties
- the properties of the output format
-
getOutputProperties
Get the properties for xsl:output. The object returned will be a clone of the internal values, and thus it can be mutated without mutating the Executable object.The returned properties object is a new, empty, Properties object that is backed by the live properties to supply default values for missing properties. This means that the property values must be read using the getProperty() method. Calling the get() method on the underlying Hashtable will return null.
This method gets the output properties for the unnamed output format in the stylesheet.
- Returns:
- A Properties object reflecting the output properties defined for the default (unnamed) output format in the stylesheet. It may be mutated and supplied to the setOutputProperties() method of the Transformer, without affecting other transformations that use the same stylesheet.
- See Also:
-
getOutputProperties
Get a named output format- Parameters:
qName
- the name of the output format- Returns:
- properties the properties of the output format. Return null if there are no output properties with the given name
-
addQueryLibraryModule
Add an XQuery library module to the configuration. The Executable maintains a table indicating for each module namespace, the set of modules that have been loaded from that namespace. If a module import is encountered that specifies no location hint, all the known modules for that namespace are imported.- Parameters:
module
- the library module to be added to this executable
-
getQueryLibraryModules
Locate the known XQuery library modules for a given module namespace.- Parameters:
namespace
- the module namespace URI- Returns:
- a list of items each of which is the StaticQueryContext representing a module, or null if the module namespace is unknown
-
getQueryModuleWithSystemId
Get the query library module with a given systemID- Parameters:
systemId
- the SystemId of the required moduletopModule
- the top-level query module (usually a main module, except when importing library modules into XSLT)- Returns:
- the module with that system id if found, otherwise null
-
getQueryLibraryModules
Get an iterator over all the query library modules (does not include the main module)- Returns:
- an iterator whose returned items are instances of
QueryModule
-
addQueryLocationHintProcessed
Add a name to the list of query module location hints that have been processed during the construction of this executable- Parameters:
uri
- the name to be added (the location URI as it appears in the "import module" declaration, expanded to an absolute URI by resolving against the base URI, but before passing to the Module Resolver)
-
isQueryLocationHintProcessed
Ask whether a query module location hint has already been processed- Parameters:
uri
- the query location hint (the location URI as it appears in the "import module" declaration, expanded to an absolute URI by resolving against the base URI, but before passing to the Module Resolver)- Returns:
- true if the location hint has already been processed
-
fixupQueryModules
Fix up global variables and functions in all query modules. This is done right at the end, because recursive imports are permitted- Parameters:
main
- the main query module- Throws:
XPathException
- if an error occurs
-
explainGlobalVariables
Explain (that is, output an expression tree) the global variables- Parameters:
presenter
- the destination for the explanation of the global variables- Throws:
XPathException
- if writing to the output fails
-
registerGlobalParameter
Register a global parameter- Parameters:
param
- the stylesheet parameter (XSLT) or external variable (XQuery) to be registered
-
getGlobalParameters
Get all the registered global parameters- Returns:
- a list of all the stylesheet parameters (XSLT) or external variables (XQuery)
-
getGlobalParameter
Get the global parameter with a given name, if there is one- Parameters:
name
- the parameter name- Returns:
- the global parameter with this name, if it exists, or null otherwise
-
checkSuppliedParameters
Check the supplied parameters. Checks that all required parameters have been supplied, and that no parameters supplied at run-time are declared static in the stylesheet, or were supplied eagerly at compile-time.Used in XSLT only.
- Parameters:
params
- the set of parameters that have been supplied (null represents an empty set)- Throws:
XPathException
- if there is a required parameter for which no value has been supplied
-
setCreatesSecondaryResult
public void setCreatesSecondaryResult(boolean flag) Set whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documents- Parameters:
flag
- true if the executable uses xsl:result-document
-
createsSecondaryResult
public boolean createsSecondaryResult()Ask whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documents- Returns:
- true if the executable uses xsl:result-document
-
setGlobalContextRequirement
Set the accumulators declared on xsl:global-context-item- Parameters:
requirement
- the requirements on the global context item
-
getGlobalContextRequirement
Get the constraints on the initial global context item- Returns:
- the declared initial global context item requirements
-
checkInitialContextItem
Check that the supplied global context item meets all requirements, and perform any required conversions or defaulting- Parameters:
contextItem
- the supplied context itemcontext
- a context for evaluation (in which the context item will be absent)- Returns:
- a new/converted context item, or null if the global context item is to be absent
- Throws:
XPathException
- if the supplied item does not meet requirements, for example if it is the wrong type.
-
setSchemaAware
public void setSchemaAware(boolean aware) Set whether this executable is schema-aware. The initial value is false; it is set to true at compile time if the query or transformation imports a schema. If the value is false, then all documents used at run-time must be untyped- Parameters:
aware
- true if the executable is schema-aware- Throws:
IllegalArgumentException
- if schema-aware processing is requested in a Configuration that is not schema-aware
-
isSchemaAware
public boolean isSchemaAware()Ask whether this executable is schema-aware, that is, whether the query or transformation imports a schema.- Returns:
- true if the executable is schema-aware, false if not.
-