net.sf.saxon.instruct

Class Executable

public class Executable extends Object implements Serializable

A compiled stylesheet or a query in executable form. Note that the original stylesheet tree is not retained.
Constructor Summary
Executable(Configuration config)
Create a new Executable (a collection of stylesheet modules and/or query modules)
Method Summary
voidaddQueryLibraryModule(QueryModule module)
Add an XQuery library module to the configuration.
voidaddRequiredParam(StructuredQName qName)
Add a required parameter
voidcheckAllRequiredParamsArePresent(GlobalParameterSet params)
Check that all required parameters have been supplied
booleancreatesSecondaryResult()
Ask whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documents
voidexplainGlobalVariables(ExpressionPresenter presenter)
Explain (that is, output an expression tree) the global variables
voidexplainNamedTemplates(ExpressionPresenter presenter)
Explain the expression tree for named templates in a stylesheet
voidfixupQueryModules(QueryModule main)
Fix up global variables and functions in all query modules.
HashMap<StructuredQName,IntHashMap<String>>getCharacterMapIndex()
Get the index of named character maps
CollationMapgetCollationTable()
Get the table of collations
HashMap<StructuredQName,GlobalVariable>getCompiledGlobalVariables()
Get the index of global variables
ConfigurationgetConfiguration()
Get the configuration
PropertiesgetDefaultOutputProperties()
Get the default output properties
FunctionLibrarygetFunctionLibrary()
Get the library containing all the in-scope functions in the static context
GlobalVariablegetGlobalVariable(StructuredQName name)
Get the global variable with a given name
SlotManagergetGlobalVariableMap()
Get the global variable map
intgetHostLanguage()
Get the host language
StructuredQNamegetInitialContextItemVariableName()
Get the the name of the variable that will implicitly contain the value of the initial context item.
KeyManagergetKeyManager()
Get the KeyManager which handles key definitions
intgetLargestPatternStackFrame()
Determine the size of the stack frame needed for evaluating match patterns
LocationMapgetLocationMap()
Get the location map
StringCollatorgetNamedCollation(String name)
Find a named collation.
TemplategetNamedTemplate(StructuredQName qName)
Get the named template with a given name.
PropertiesgetOutputProperties(StructuredQName qName)
Get a named output format
List<QueryModule>getQueryLibraryModules(String namespace)
Locate the known XQuery library modules for a given module namespace.
IteratorgetQueryLibraryModules()
Get an iterator over all the query library modules (does not include the main module)
QueryModulegetQueryModuleWithSystemId(String systemId, QueryModule topModule)
Get the query library module with a given systemID
StringgetReasonUnableToCompile()
Determine whether this executable can be compiled; and if it can't, return the reason why
RuleManagergetRuleManager()
Get the RuleManager which handles template rules
ModegetStripperRules()
Get the rules determining which nodes are to be stripped from the tree
voidinitializeBindery(Bindery bindery)
Allocate space in bindery for all the variables needed
booleanisSchemaAware()
Ask whether this executable is schema-aware, that is, whether the query or transformation imports a schema.
Iterator<Template>iterateNamedTemplates()
Iterate over all the named templates defined in this Executable
StrippernewStripper()
Create a Stripper which handles whitespace stripping definitions
voidputNamedTemplate(StructuredQName templateName, Template template)
Register the named template with a given name
voidregisterGlobalVariable(GlobalVariable variable)
Register a global variable
voidsetCharacterMapIndex(HashMap<StructuredQName,IntHashMap<String>> cmi)
Set the index of named character maps
voidsetCollationTable(CollationMap table)
Set the table of collations
voidsetConfiguration(Configuration config)
Set the configuration
voidsetCreatesSecondaryResult(boolean flag)
Set whether this executable represents a stylesheet that uses xsl:result-document to create secondary output documents
voidsetDefaultOutputProperties(Properties properties)
Set the default output properties (the properties for the unnamed output format)
voidsetFunctionLibrary(FunctionLibrary functionLibrary)
Set the library containing all the in-scope functions in the static context
voidsetHostLanguage(int language)
Set the host language
voidsetInitialContextItemVariableName(StructuredQName name)
Set the name of the variable that will implicitly contain the value of the initial context item.
voidsetKeyManager(KeyManager km)
Set the KeyManager which handles key definitions
voidsetLocationMap(LocationMap map)
Set the location map
voidsetOutputProperties(StructuredQName qName, Properties properties)
Add a named output format
voidsetPatternSlotSpace(int patternLocals)
Set the space requirements for variables used in template match patterns
voidsetReasonUnableToCompile(String reason)
If this Executable can't be compiled, set a message explaining why
voidsetRuleManager(RuleManager rm)
Set the RuleManager that handles template rules
voidsetSchemaAware(boolean aware)
Set whether this executable is schema-aware.
voidsetStripperRules(Mode rules)
Set the rules determining which nodes are to be stripped from the tree
voidsetStripsInputTypeAnnotations(boolean strips)
Set whether source documents are to have their type annotations stripped
voidsetStripsWhitespace(boolean strips)
Indicate that the stylesheet does some whitespace stripping
booleanstripsInputTypeAnnotations()
Ask whether source documents are to have their type annotations stripped
booleanstripsWhitespace()
Determine whether this stylesheet does any whitespace stripping

Constructor Detail

Executable

public Executable(Configuration config)
Create a new Executable (a collection of stylesheet modules and/or query modules)

Parameters: config the Saxon Configuration

Method Detail

addQueryLibraryModule

public void addQueryLibraryModule(QueryModule module)
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

addRequiredParam

public void addRequiredParam(StructuredQName qName)
Add a required parameter

Parameters: qName the name of the required parameter

checkAllRequiredParamsArePresent

public void checkAllRequiredParamsArePresent(GlobalParameterSet params)
Check that all required parameters have been supplied

Parameters: params the set of parameters that have been supplied

Throws: XPathException if there is a required parameter for which no value has been supplied

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

explainGlobalVariables

public void explainGlobalVariables(ExpressionPresenter presenter)
Explain (that is, output an expression tree) the global variables

Parameters: presenter the destination for the explanation of the global variables

explainNamedTemplates

public void explainNamedTemplates(ExpressionPresenter presenter)
Explain the expression tree for named templates in a stylesheet

Parameters: presenter destination for the explanatory output

fixupQueryModules

public void fixupQueryModules(QueryModule main)
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

getCharacterMapIndex

public HashMap<StructuredQName,IntHashMap<String>> 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

getCollationTable

public CollationMap getCollationTable()
Get the table of collations

Returns: a hash table that maps collation names (URIs) to objects representing the collation information

getCompiledGlobalVariables

public HashMap<StructuredQName,GlobalVariable> getCompiledGlobalVariables()
Get the index of global variables

Returns: the index of global variables. This is a HashMap in which the key is the StructuredQName of the variable name, and the value is the GlobalVariable object representing the compiled global variable. If there are no global variables, the method may return null.

getConfiguration

public Configuration getConfiguration()
Get the configuration

Returns: the Configuration

getDefaultOutputProperties

public Properties getDefaultOutputProperties()
Get the default output properties

Returns: the properties for the unnamed output format

getFunctionLibrary

public FunctionLibrary getFunctionLibrary()
Get the library containing all the in-scope functions in the static context

Returns: the function libary

getGlobalVariable

public GlobalVariable getGlobalVariable(StructuredQName name)
Get the global variable with a given name

Parameters: name the name of the required variable

Returns: the GlobalVariable with this name, or null if not found

getGlobalVariableMap

public SlotManager getGlobalVariableMap()
Get the global variable map

Returns: the SlotManager defining the allocation of slots to global variables

getHostLanguage

public int getHostLanguage()
Get the host language

Returns: a value identifying the host language: XQUERY or XSLT or JAVA_APPLICATION

getInitialContextItemVariableName

public StructuredQName getInitialContextItemVariableName()
Get the the name of the variable that will implicitly contain the value of the initial context item. The properties of this variable, such as its required type and initial value, automatically apply to the initial context item

Returns: the name of the global variable that mirrors the initial context item

getKeyManager

public KeyManager getKeyManager()
Get the KeyManager which handles key definitions

Returns: the KeyManager containing the xsl:key definitions

getLargestPatternStackFrame

public int getLargestPatternStackFrame()
Determine the size of the stack frame needed for evaluating match patterns

Returns: the size of the largest stack frame needed for evaluating the match patterns that appear in XSLT template rules

getLocationMap

public LocationMap getLocationMap()
Get the location map

Returns: the location map, which is used to identify the locations of errors

getNamedCollation

public StringCollator getNamedCollation(String name)
Find a named collation.

Parameters: name identifies the name of the collation required; null indicates that the default collation is required

Returns: the requested collation, or null if the collation is not found

getNamedTemplate

public Template getNamedTemplate(StructuredQName qName)
Get the named template with a given name.

Parameters: qName The template name

Returns: The template (of highest import precedence) with this name if there is one; null if none is found.

getOutputProperties

public Properties getOutputProperties(StructuredQName qName)
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

getQueryLibraryModules

public List<QueryModule> getQueryLibraryModules(String namespace)
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

getQueryLibraryModules

public Iterator 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

getQueryModuleWithSystemId

public QueryModule getQueryModuleWithSystemId(String systemId, QueryModule topModule)
Get the query library module with a given systemID

Parameters: systemId the SystemId of the required module topModule 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

getReasonUnableToCompile

public String getReasonUnableToCompile()
Determine whether this executable can be compiled; and if it can't, return the reason why

Returns: null if the executable can be compiled, or a message otherwise

getRuleManager

public RuleManager getRuleManager()
Get the RuleManager which handles template rules

Returns: the RuleManager registered with setRuleManager

getStripperRules

public Mode getStripperRules()
Get the rules determining which nodes are to be stripped from the tree

Returns: a Mode object containing the whitespace stripping rules. A Mode is generally a collection of template rules, but it is reused here to represent a collection of stripping rules.

initializeBindery

public void initializeBindery(Bindery bindery)
Allocate space in bindery for all the variables needed

Parameters: bindery The bindery to be initialized

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.

iterateNamedTemplates

public Iterator<Template> iterateNamedTemplates()
Iterate over all the named templates defined in this Executable

Returns: an iterator, the items returned being of class Template

newStripper

public Stripper newStripper()
Create a Stripper which handles whitespace stripping definitions

Returns: the constructed Stripper object

putNamedTemplate

public void putNamedTemplate(StructuredQName templateName, Template template)
Register the named template with a given name

Parameters: templateName the name of a named XSLT template template the template

registerGlobalVariable

public void registerGlobalVariable(GlobalVariable variable)
Register a global variable

Parameters: variable the global variable to be registered

setCharacterMapIndex

public void setCharacterMapIndex(HashMap<StructuredQName,IntHashMap<String>> cmi)
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

setCollationTable

public void setCollationTable(CollationMap table)
Set the table of collations

Parameters: table a hash table that maps collation names (URIs) to objects representing the collation information

setConfiguration

public void setConfiguration(Configuration config)
Set the configuration

Parameters: config the Configuration

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

setDefaultOutputProperties

public void setDefaultOutputProperties(Properties properties)
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

setFunctionLibrary

public void setFunctionLibrary(FunctionLibrary functionLibrary)
Set the library containing all the in-scope functions in the static context

Parameters: functionLibrary the function libary

setHostLanguage

public void setHostLanguage(int language)
Set the host language

Parameters: language the host language, as a constant such as XSLT or XQUERY

setInitialContextItemVariableName

public void setInitialContextItemVariableName(StructuredQName name)
Set the name of the variable that will implicitly contain the value of the initial context item. The properties of this variable, such as its required type and initial value, automatically apply to the initial context item

Parameters: name the name of the global variable that mirrors the initial context item

setKeyManager

public void setKeyManager(KeyManager km)
Set the KeyManager which handles key definitions

Parameters: km the KeyManager containing the xsl:key definitions

setLocationMap

public void setLocationMap(LocationMap map)
Set the location map

Parameters: map the location map, which is used to identify the module URI and line number of locations of errors

setOutputProperties

public void setOutputProperties(StructuredQName qName, Properties properties)
Add a named output format

Parameters: qName the structured QName of the output format properties the properties of the output format

setPatternSlotSpace

public void setPatternSlotSpace(int patternLocals)
Set the space requirements for variables used in template match patterns

Parameters: patternLocals The largest number of local variables used in the match pattern of any template rule

setReasonUnableToCompile

public void setReasonUnableToCompile(String reason)
If this Executable can't be compiled, set a message explaining why

Parameters: reason a message explaining why compilation is not possible

setRuleManager

public void setRuleManager(RuleManager rm)
Set the RuleManager that handles template rules

Parameters: rm the RuleManager containing details of all the template rules

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

setStripperRules

public void setStripperRules(Mode rules)
Set the rules determining which nodes are to be stripped from the tree

Parameters: rules a Mode object containing the whitespace stripping rules. A Mode is generally a collection of template rules, but it is reused here to represent a collection of stripping rules.

setStripsInputTypeAnnotations

public void setStripsInputTypeAnnotations(boolean strips)
Set whether source documents are to have their type annotations stripped

Parameters: strips true if type annotations are to be stripped

setStripsWhitespace

public void setStripsWhitespace(boolean strips)
Indicate that the stylesheet does some whitespace stripping

Parameters: strips true if the stylesheet performs whitespace stripping of one or more elements.

stripsInputTypeAnnotations

public boolean stripsInputTypeAnnotations()
Ask whether source documents are to have their type annotations stripped

Returns: true if type annotations are stripped from source documents

stripsWhitespace

public boolean stripsWhitespace()
Determine whether this stylesheet does any whitespace stripping

Returns: true if the stylesheet performs whitespace stripping of one or more elements.