Package net.sf.saxon.style
Class StylesheetPackage
java.lang.Object
net.sf.saxon.expr.PackageData
net.sf.saxon.style.StylesheetPackage
- Direct Known Subclasses:
StylesheetPackageEE
A (compiled) stylesheet package. This may be created either by compiling a source XSLT package,
or by loading a saved package from disk. It therefore has no references to source XSLT documents.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Properties
protected GlobalContextRequirement
protected Map
<StructuredQName, Properties> protected HashMap
<SymbolicName, Component> protected Set
<NamespaceUri> protected SpaceStrippingRule
Fields inherited from class net.sf.saxon.expr.PackageData
config, hostLanguageVersion, keyManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCompletionAction
(Action action) Register a callback action to be performed during the completion phase of building the packagevoid
addComponent
(Component component) Add a component to the packagevoid
addComponentsFromUsedPackage
(StylesheetPackage usedPackage, List<XSLAccept> acceptors, Set<SymbolicName> overrides) Add modified copies of components from a package that is referenced from this one in an xsl:use-package declarationvoid
addGlobalVariable
(GlobalVariable variable) Add a global variable to the list of global variables contained in this packagevoid
addHiddenComponent
(Component component) protected void
addIxsl3FunctionLibrary
(FunctionLibraryList functionLibrary) protected void
addIxslFunctionLibrary
(FunctionLibraryList functionLibrary) void
protected void
addStubFunctionLibrary
(FunctionLibrary stubFunctions) void
Add a package to the list of packages directly used by this onevoid
Allocate slots to global variables.void
protected void
complete()
Perform all registered completion actions for the packageboolean
contains
(StylesheetPackage pack) Ask whether a given library package is within the package subtree rooted at this packagevoid
Create the function library containing stylesheet functions declared in this packagevoid
export
(ExpressionPresenter presenter) Output the abstract expression tree to the supplied destination.Get the index of named character maps defined in this packagegetComponent
(SymbolicName name) Get the component within this package having a given symbolic nameGet a map containing all the components in this package, indexed by symbolic nameGet the required context item type and other details of the global context item.Get the default mode for the packagegetFunction
(SymbolicName.F name) Get the function with a given name and arityGet the function library.int
Get the maximum arity of functions in this packageGet a set of named output propertiesIf this component overrides a component named N, get the component that N overrides (that is, the component identified by xsl:original appearing within the overriding declaration of N)Get the name identifier of the xsl:package as an absolute URIGet the package-version identifier appearing on the xsl:package elementGet the library of functions exposed by this stylesheet package, that is, functions whose visibility is public or finalGet the rule manager, which knows about all the modes present in the packageGet the set of namespaces of schema declarations imported into this packageGet the whitespace stripping rules for this packageGet the whitespace stripping rules for source documents loaded from within this packageGet the packages referenced from this package in an xsl:use-package declarationGet the library of functions imported from XQueryboolean
Ask whether the package contains an xsl:result-document instructionboolean
Ask whether it is required that modes be explicitly declaredboolean
Ask whether a non-streamable construct has been found, forcing the entire stylesheet to fall back to unstreamed processingboolean
Ask if this is an implicit package (one rooted at xsl:stylesheet or xsl:transform rather than xsl:packageboolean
Ask whether the package was compiled with just-in-time compilation of template rules enabledboolean
Ask whether private functions for which there are no static references need to be retainedboolean
Ask whether the package defines that type annotations should be stripped from input documents loaded from within this packageboolean
Ask whether there is an xsl:strip-space declaration in the stylesheet packagevoid
markNonExportable
(String message, String errorCode) Mark the package as non-exportable, supplying an error message to be reported if export is attemptedvoid
setCharacterMapIndex
(CharacterMapIndex characterMapIndex) Set the index of named character maps defined in this packagevoid
setContextItemRequirements
(GlobalContextRequirement requirement) Set the required context item type.void
setCreatesSecondaryResultDocuments
(boolean createsSecondaryResultDocuments) Say whether the package contains an xsl:result-document instructionvoid
setDeclaredModes
(boolean declared) Say whether it is required that modes be explicitly declaredvoid
setDefaultMode
(StructuredQName defaultMode) Set the default mode for the packagevoid
Set the default (unnamed) serialization properties to be used for documents output using xsl:result-document instructions within this packagevoid
void
setFunctionLibraryDetails
(FunctionLibraryList library, ExecutableFunctionLibrary overriding, ExecutableFunctionLibrary underriding) Set details of functions available for calling anywhere in this package.void
setImplicitPackage
(boolean implicitPackage) Say whether this is an implicit package (one rooted at xsl:stylesheet or xsl:transform rather than xsl:packagevoid
setJustInTimeCompilation
(boolean justInTimeCompilation) Say whether the package was compiled with just-in-time compilation of template rules enabled.void
setLanguageVersion
(int version) Set the version of the XSLT language specification to which the package manifest conformsvoid
setNamedOutputProperties
(StructuredQName name, Properties props) Define a named set serialization properties to be used for documents output using xsl:result-document instructions within this packagevoid
setPackageName
(String packageName) Set the name of the packagevoid
setPackageVersion
(PackageVersion version) Set the package-version identifier appearing on the xsl:package elementvoid
Say that private functions need to be retained, typically because the stylesheet package uses xsl:evaluate or fn:function-lookupvoid
setRuleManager
(RuleManager ruleManager) Set the rule manager, which knows about all the modes present in the packagevoid
setStripperRules
(SpaceStrippingRule stripperRules) Set the whitespace stripping rules for source documents loaded from within this packagevoid
setStripsTypeAnnotations
(boolean stripsTypeAnnotations) Say whether the package defines that type annotations should be stripped from input documents loaded from within this packagevoid
setStripsWhitespace
(boolean strips) Say whether there is an xsl:strip-space declaration in the stylesheet packagevoid
Copy information from this package to the PreparedStylesheet.Methods inherited from class net.sf.saxon.expr.PackageData
getAccumulatorRegistry, getConfiguration, getDecimalFormatManager, getGlobalSlotManager, getGlobalVariableList, getHostLanguage, getHostLanguageVersion, getKeyManager, getLocalLicenseId, getTargetEdition, isRelocatable, isSchemaAware, isXSLT, obtainTypeAliasManager, setAccumulatorRegistry, setConfiguration, setDecimalFormatManager, setGlobalSlotManager, setHostLanguage, setKeyManager, setLocalLicenseId, setRelocatable, setSchemaAware, setTargetEdition, setTypeAliasManager
-
Field Details
-
globalContextRequirement
-
stripperRules
-
defaultOutputProperties
-
namedOutputProperties
-
schemaIndex
-
overriddenComponents
-
-
Constructor Details
-
StylesheetPackage
Create a stylesheet package- Parameters:
config
- the Saxon Configuration
-
-
Method Details
-
getComponentIndex
Get a map containing all the components in this package, indexed by symbolic name- Returns:
- a map containing all the components in the package. This does not include components in used packages, except to the extent that they have been copied into this package.
-
getUsedPackages
Get the packages referenced from this package in an xsl:use-package declaration- Returns:
- the packages used by this package
-
addUsedPackage
Add a package to the list of packages directly used by this one- Parameters:
pack
- the used package
-
contains
Ask whether a given library package is within the package subtree rooted at this package- Parameters:
pack
- the library package- Returns:
- true if the given library package is in the transitive contents of this package
-
setLanguageVersion
public void setLanguageVersion(int version) Set the version of the XSLT language specification to which the package manifest conforms- Parameters:
version
- the version (times ten) as an integer
-
setPackageName
Set the name of the package- Parameters:
packageName
- the name of the package. This is supposed to be an absolute URI, but Saxon accepts any string.
-
getPackageVersion
Get the package-version identifier appearing on the xsl:package element- Returns:
- the version identifier as a structured entity
-
setPackageVersion
Set the package-version identifier appearing on the xsl:package element- Parameters:
version
- the version identifier as a structured entity
-
getPackageName
Get the name identifier of the xsl:package as an absolute URI- Returns:
- a string value. This is supposed to be an absolute URI, but Saxon accepts any string.
-
isImplicitPackage
public boolean isImplicitPackage()Ask if this is an implicit package (one rooted at xsl:stylesheet or xsl:transform rather than xsl:package- Returns:
- true if this package was rooted at an xsl:stylesheet or xsl:transform element
-
setImplicitPackage
public void setImplicitPackage(boolean implicitPackage) Say whether this is an implicit package (one rooted at xsl:stylesheet or xsl:transform rather than xsl:package- Parameters:
implicitPackage
- true if this package was rooted at an xsl:stylesheet or xsl:transform element
-
isJustInTimeCompilation
public boolean isJustInTimeCompilation()Ask whether the package was compiled with just-in-time compilation of template rules enabled- Returns:
- false (always) for Saxon-HE
-
setJustInTimeCompilation
public void setJustInTimeCompilation(boolean justInTimeCompilation) Say whether the package was compiled with just-in-time compilation of template rules enabled. This method is called by the compiler itself and should not be called by users. The setting is ignored in Saxon-HE.- Parameters:
justInTimeCompilation
- set to true if just-in-time compilation was enabled when the package was compiled
-
getRuleManager
Get the rule manager, which knows about all the modes present in the package- Returns:
- the rule manager
-
setRuleManager
Set the rule manager, which knows about all the modes present in the package- Parameters:
ruleManager
- the rule manager
-
getDefaultMode
Get the default mode for the package- Returns:
- the default mode for the package as a whole (this may change for individual elements/subtrees within the package)
-
setDefaultMode
Set the default mode for the package- Parameters:
defaultMode
- the default mode for the package
-
setDeclaredModes
public void setDeclaredModes(boolean declared) Say whether it is required that modes be explicitly declared- Parameters:
declared
- true if modes referenced within this package must be explicitly declared
-
isDeclaredModes
public boolean isDeclaredModes()Ask whether it is required that modes be explicitly declared- Returns:
- true if modes referenced within this package must be explicitly declared
-
getSpaceStrippingRule
Get the whitespace stripping rules for this package- Returns:
- the whitespace stripping rules (based on xsl:strip-space and xsl:preserve-space)
-
getCharacterMapIndex
Get the index of named character maps defined in this package- Returns:
- the index of character maps
-
setCharacterMapIndex
Set the index of named character maps defined in this package- Parameters:
characterMapIndex
- the index of named character maps
-
isCreatesSecondaryResultDocuments
public boolean isCreatesSecondaryResultDocuments()Ask whether the package contains 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 package contains an xsl:result-document instruction- Parameters:
createsSecondaryResultDocuments
- true if the package contains an xsl:result-document instruction
-
isStripsTypeAnnotations
public boolean isStripsTypeAnnotations()Ask whether the package defines that type annotations should be stripped from input documents loaded from within this package- Returns:
- true if documents loaded by this package should have any type annotations stripped.
-
setStripsTypeAnnotations
public void setStripsTypeAnnotations(boolean stripsTypeAnnotations) Say whether the package defines that type annotations should be stripped from input documents loaded from within this package- Parameters:
stripsTypeAnnotations
- set to true if documents loaded by this package should have any type annotations stripped.
-
getStripperRules
Get the whitespace stripping rules for source documents loaded from within this package- Returns:
- the whitespace stripping rules for this package
-
setStripperRules
Set the whitespace stripping rules for source documents loaded from within this package- Parameters:
stripperRules
- the whitespace stripping rules for this package
-
setDefaultOutputProperties
Set the default (unnamed) serialization properties to be used for documents output using xsl:result-document instructions within this package- Parameters:
props
- the default serialization properties for this package
-
setNamedOutputProperties
Define a named set serialization properties to be used for documents output using xsl:result-document instructions within this package- Parameters:
name
- the name of the serialization property setprops
- the serialization properties
-
getNamedOutputProperties
Get a set of named output properties- Parameters:
name
- the output declaration name- Returns:
- the corresponding properties; or null if the name is unknown
-
getSchemaNamespaces
Get the set of namespaces of schema declarations imported into this package- Returns:
- the set of imported namespaces
-
setContextItemRequirements
Set the required context item type. Used when there is an xsl:global-context-item child element- Parameters:
requirement
- details of the requirement for the global context item- Throws:
XPathException
- if there are conflicts
-
getContextItemRequirements
Get the required context item type and other details of the global context item. Used when there is an xsl:global-context-item child element- Returns:
- details of the requirement for the global context item
-
setStripsWhitespace
public void setStripsWhitespace(boolean strips) Say whether there is an xsl:strip-space declaration in the stylesheet package- Parameters:
strips
- true if an xsl:strip-space declaration has been found
-
isStripsWhitespace
public boolean isStripsWhitespace()Ask whether there is an xsl:strip-space declaration in the stylesheet package- Returns:
- true if an xsl:strip-space declaration has been found
-
addCompletionAction
Register a callback action to be performed during the completion phase of building the package- Parameters:
action
- the callback action
-
complete
Perform all registered completion actions for the package- Throws:
XPathException
- if any of these completion actions fails
-
allocateBinderySlots
public void allocateBinderySlots()Allocate slots to global variables. Slot numbers are unique within a package -
addComponent
Add a component to the package- Parameters:
component
- the component to be added
-
addGlobalVariable
Description copied from class:PackageData
Add a global variable to the list of global variables contained in this package- Overrides:
addGlobalVariable
in classPackageData
- Parameters:
variable
- the global variable to be added
-
getMaxFunctionArity
public int getMaxFunctionArity()Get the maximum arity of functions in this package- Returns:
- the maximum arity
-
getComponent
Get the component within this package having a given symbolic name- Parameters:
name
- the symbolic name of the required component- Returns:
- the requested component, or null if it does not exist in the package
-
addHiddenComponent
-
getOverriddenComponent
If this component overrides a component named N, get the component that N overrides (that is, the component identified by xsl:original appearing within the overriding declaration of N)- Parameters:
name
- the name N- Returns:
- if there is an overriding declaration of N, then the original declaration of N from the used package; otherwise null
-
addOverriddenComponent
-
addComponentsFromUsedPackage
public void addComponentsFromUsedPackage(StylesheetPackage usedPackage, List<XSLAccept> acceptors, Set<SymbolicName> overrides) throws XPathException Add modified copies of components from a package that is referenced from this one in an xsl:use-package declaration- Parameters:
usedPackage
- the used packageacceptors
- abstraction of a list of xsl:accept declarations, which can modify the visibility of accepted componentsoverrides
- the set of names of components from the used package that are overridden in the using package- Throws:
XPathException
- if duplicate components are found
-
createFunctionLibrary
public void createFunctionLibrary()Create the function library containing stylesheet functions declared in this package -
addIxslFunctionLibrary
-
addIxsl3FunctionLibrary
-
addStubFunctionLibrary
-
getFunctionLibrary
Get the function library.- Returns:
- the function library
-
getPublicFunctions
Get the library of functions exposed by this stylesheet package, that is, functions whose visibility is public or final- Returns:
- a function library containing only the functions that are exposed as public
-
getXQueryFunctionLibrary
Get the library of functions imported from XQuery- Returns:
- the XQuery function library
-
setFunctionLibraryDetails
public void setFunctionLibraryDetails(FunctionLibraryList library, ExecutableFunctionLibrary overriding, ExecutableFunctionLibrary underriding) Set details of functions available for calling anywhere in this package. This is the function library used for resolving run-time references to functions, for example from xsl:evaluate, function-available(), or function-lookup().- Parameters:
library
- the main function library (as a list of sub-libraries)overriding
- library of stylesheet functions declared with override=yesunderriding
- library of stylesheet functions declared with override=no
-
getFunction
Get the function with a given name and arity- Parameters:
name
- the symbolic name of the function (QName plus arity)- Returns:
- the requested function, or null if none can be found
-
isRetainUnusedFunctions
public boolean isRetainUnusedFunctions()Ask whether private functions for which there are no static references need to be retained- Returns:
- true if such functions need to be retained, typically because the stylesheet package uses xsl:evaluate or fn:function-lookup
-
setRetainUnusedFunctions
public void setRetainUnusedFunctions()Say that private functions need to be retained, typically because the stylesheet package uses xsl:evaluate or fn:function-lookup -
updatePreparedStylesheet
Copy information from this package to the PreparedStylesheet.- Parameters:
pss
- the PreparedStylesheet to be updated- Throws:
XPathException
- if the PreparedStylesheet cannot be updated
-
getAbstractComponents
-
markNonExportable
Mark the package as non-exportable, supplying an error message to be reported if export is attempted- Parameters:
message
- the error message to report indicating why export is not possibleerrorCode
- the error code to report if export is attempted
-
export
Output the abstract expression tree to the supplied destination.- Parameters:
presenter
- the expression presenter used to display the structure- Throws:
XPathException
- if exporting fails or is not permitted (it requires Saxon-EE)
-
checkForAbstractComponents
- Throws:
XPathException
-
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()
-