Package net.sf.saxon.style
Class StylesheetPackage
- java.lang.Object
-
- net.sf.saxon.expr.PackageData
-
- net.sf.saxon.style.StylesheetPackage
-
- Direct Known Subclasses:
StylesheetPackageEE
public class StylesheetPackage extends PackageData
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
Fields Modifier and Type Field Description protected java.util.Properties
defaultOutputProperties
protected GlobalContextRequirement
globalContextRequirement
protected java.util.List<Component>
hiddenComponents
protected java.util.Map<StructuredQName,java.util.Properties>
namedOutputProperties
protected java.util.HashMap<SymbolicName,Component>
overriddenComponents
protected java.util.Set<java.lang.String>
schemaIndex
protected SpaceStrippingRule
stripperRules
-
Fields inherited from class net.sf.saxon.expr.PackageData
config, keyManager
-
-
Constructor Summary
Constructors Constructor Description StylesheetPackage(Configuration config)
Create a stylesheet package
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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, java.util.List<XSLAccept> acceptors, java.util.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
addIxslFunctionLibrary(FunctionLibraryList functionLibrary)
void
addOverriddenComponent(Component comp)
void
addUsedPackage(StylesheetPackage pack)
Add a package to the list of packages directly used by this onevoid
allocateBinderySlots()
Allocate slots to global variables.void
checkForAbstractComponents()
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
createFunctionLibrary()
Create the function library containing stylesheet functions declared in this packagevoid
export(ExpressionPresenter presenter)
Output the abstract expression tree to the supplied destination.java.util.Map<SymbolicName,Component>
getAbstractComponents()
CharacterMapIndex
getCharacterMapIndex()
Get the index of named character maps defined in this packageComponent
getComponent(SymbolicName name)
Get the component within this package having a given symbolic namejava.util.HashMap<SymbolicName,Component>
getComponentIndex()
Get a map containing all the components in this package, indexed by symbolic nameGlobalContextRequirement
getContextItemRequirements()
Get the required context item type and other details of the global context item.StructuredQName
getDefaultMode()
Get the default mode for the packageprotected UserFunction
getFunction(SymbolicName.F name)
Get the function with a given name and arityFunctionLibraryList
getFunctionLibrary()
Get the function library.int
getMaxFunctionArity()
Get the maximum arity of functions in this packagejava.util.Properties
getNamedOutputProperties(StructuredQName name)
Get a set of named output propertiesComponent
getOverriddenComponent(SymbolicName name)
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)java.lang.String
getPackageName()
Get the name identifier of the xsl:package as an absolute URIPackageVersion
getPackageVersion()
Get the package-version identifier appearing on the xsl:package elementFunctionLibrary
getPublicFunctions()
Get the library of functions exposed by this stylesheet package, that is, functions whose visibility is public or finalRuleManager
getRuleManager()
Get the rule manager, which knows about all the modes present in the packagejava.util.Set<java.lang.String>
getSchemaNamespaces()
Get the set of namespaces of schema declarations imported into this packageSpaceStrippingRule
getSpaceStrippingRule()
Get the whitespace stripping rules for this packageSpaceStrippingRule
getStripperRules()
Get the whitespace stripping rules for source documents loaded from within this packagejava.lang.Iterable<StylesheetPackage>
getUsedPackages()
Get the packages referenced from this package in an xsl:use-package declarationint
getVersion()
Get the version of the XSLT language specification to which the package manifest conformsXQueryFunctionLibrary
getXQueryFunctionLibrary()
Get the library of functions imported from XQueryboolean
isCreatesSecondaryResultDocuments()
Ask whether the package contains an xsl:result-document instructionboolean
isDeclaredModes()
Ask whether it is required that modes be explicitly declaredboolean
isFallbackToNonStreaming()
Ask whether a non-streamable construct has been found, forcing the entire stylesheet to fall back to unstreamed processingboolean
isImplicitPackage()
Ask if this is an implicit package (one rooted at xsl:stylesheet or xsl:transform rather than xsl:packageboolean
isJustInTimeCompilation()
Ask whether the package was compiled with just-in-time compilation of template rules enabledboolean
isRetainUnusedFunctions()
Ask whether private functions for which there are no static references need to be retainedboolean
isStripsTypeAnnotations()
Ask whether the package defines that type annotations should be stripped from input documents loaded from within this packageboolean
isStripsWhitespace()
Ask whether there is an xsl:strip-space declaration in the stylesheet packagevoid
markNonExportable(java.lang.String message, java.lang.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
setDefaultOutputProperties(java.util.Properties props)
Set the default (unnamed) serialization properties to be used for documents output using xsl:result-document instructions within this packagevoid
setFallbackToNonStreaming()
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
setNamedOutputProperties(StructuredQName name, java.util.Properties props)
Define a named set serialization properties to be used for documents output using xsl:result-document instructions within this packagevoid
setPackageName(java.lang.String packageName)
Set the name of the packagevoid
setPackageVersion(PackageVersion version)
Set the package-version identifier appearing on the xsl:package elementvoid
setRetainUnusedFunctions()
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
setVersion(int version)
Set the version of the XSLT language specification to which the package manifest conformsvoid
updatePreparedStylesheet(PreparedStylesheet pss)
Copy information from this package to the PreparedStylesheet.-
Methods inherited from class net.sf.saxon.expr.PackageData
getAccumulatorRegistry, getConfiguration, getDecimalFormatManager, getGlobalSlotManager, getGlobalVariableList, getHostLanguage, getKeyManager, getLocalLicenseId, getTargetEdition, isRelocatable, isSchemaAware, isXSLT, obtainTypeAliasManager, setAccumulatorRegistry, setConfiguration, setDecimalFormatManager, setGlobalSlotManager, setHostLanguage, setKeyManager, setLocalLicenseId, setRelocatable, setSchemaAware, setTargetEdition, setTypeAliasManager
-
-
-
-
Field Detail
-
globalContextRequirement
protected GlobalContextRequirement globalContextRequirement
-
stripperRules
protected SpaceStrippingRule stripperRules
-
defaultOutputProperties
protected java.util.Properties defaultOutputProperties
-
namedOutputProperties
protected java.util.Map<StructuredQName,java.util.Properties> namedOutputProperties
-
schemaIndex
protected java.util.Set<java.lang.String> schemaIndex
-
hiddenComponents
protected java.util.List<Component> hiddenComponents
-
overriddenComponents
protected java.util.HashMap<SymbolicName,Component> overriddenComponents
-
-
Constructor Detail
-
StylesheetPackage
public StylesheetPackage(Configuration config)
Create a stylesheet package- Parameters:
config
- the Saxon Configuration
-
-
Method Detail
-
getComponentIndex
public java.util.HashMap<SymbolicName,Component> 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
public java.lang.Iterable<StylesheetPackage> getUsedPackages()
Get the packages referenced from this package in an xsl:use-package declaration- Returns:
- the packages used by this package
-
addUsedPackage
public void addUsedPackage(StylesheetPackage pack)
Add a package to the list of packages directly used by this one- Parameters:
pack
- the used package
-
contains
public boolean contains(StylesheetPackage pack)
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
-
setVersion
public void setVersion(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
public void setPackageName(java.lang.String packageName)
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.
-
getVersion
public int getVersion()
Get the version of the XSLT language specification to which the package manifest conforms- Returns:
- the version of the xslPackage, times ten, as an integer
-
getPackageVersion
public PackageVersion getPackageVersion()
Get the package-version identifier appearing on the xsl:package element- Returns:
- the version identifier as a structured entity
-
setPackageVersion
public void setPackageVersion(PackageVersion version)
Set the package-version identifier appearing on the xsl:package element- Parameters:
version
- the version identifier as a structured entity
-
getPackageName
public java.lang.String 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
public RuleManager getRuleManager()
Get the rule manager, which knows about all the modes present in the package- Returns:
- the rule manager
-
setRuleManager
public void setRuleManager(RuleManager ruleManager)
Set the rule manager, which knows about all the modes present in the package- Parameters:
ruleManager
- the rule manager
-
getDefaultMode
public StructuredQName 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
public void setDefaultMode(StructuredQName defaultMode)
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
public SpaceStrippingRule getSpaceStrippingRule()
Get the whitespace stripping rules for this package- Returns:
- the whitespace stripping rules (based on xsl:strip-space and xsl:preserve-space)
-
getCharacterMapIndex
public CharacterMapIndex getCharacterMapIndex()
Get the index of named character maps defined in this package- Returns:
- the index of character maps
-
setCharacterMapIndex
public void setCharacterMapIndex(CharacterMapIndex characterMapIndex)
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
public SpaceStrippingRule getStripperRules()
Get the whitespace stripping rules for source documents loaded from within this package- Returns:
- the whitespace stripping rules for this package
-
setStripperRules
public void setStripperRules(SpaceStrippingRule stripperRules)
Set the whitespace stripping rules for source documents loaded from within this package- Parameters:
stripperRules
- the whitespace stripping rules for this package
-
setDefaultOutputProperties
public void setDefaultOutputProperties(java.util.Properties props)
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
public void setNamedOutputProperties(StructuredQName name, java.util.Properties props)
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
public java.util.Properties getNamedOutputProperties(StructuredQName name)
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
public java.util.Set<java.lang.String> getSchemaNamespaces()
Get the set of namespaces of schema declarations imported into this package- Returns:
- the set of imported namespaces
-
setContextItemRequirements
public void setContextItemRequirements(GlobalContextRequirement requirement) throws XPathException
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
-
getContextItemRequirements
public GlobalContextRequirement 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
public void addCompletionAction(Action action)
Register a callback action to be performed during the completion phase of building the package- Parameters:
action
- the callback action
-
complete
protected void complete() throws XPathException
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
public void addComponent(Component component)
Add a component to the package- Parameters:
component
- the component to be added
-
addGlobalVariable
public void addGlobalVariable(GlobalVariable variable)
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
public Component getComponent(SymbolicName name)
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
public void addHiddenComponent(Component component)
-
getOverriddenComponent
public Component getOverriddenComponent(SymbolicName name)
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
public void addOverriddenComponent(Component comp)
-
addComponentsFromUsedPackage
public void addComponentsFromUsedPackage(StylesheetPackage usedPackage, java.util.List<XSLAccept> acceptors, java.util.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
protected void addIxslFunctionLibrary(FunctionLibraryList functionLibrary)
-
getFunctionLibrary
public FunctionLibraryList getFunctionLibrary()
Get the function library.- Returns:
- the function library
-
getPublicFunctions
public FunctionLibrary getPublicFunctions()
Get the library of functions exposed by this stylesheet package, that is, functions whose visibility is public or final
-
getXQueryFunctionLibrary
public XQueryFunctionLibrary 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:
overriding
- library of stylesheet functions declared with override=yesunderriding
- library of stylesheet functions declared with override=no
-
getFunction
protected UserFunction getFunction(SymbolicName.F name)
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
public void updatePreparedStylesheet(PreparedStylesheet pss) throws XPathException
Copy information from this package to the PreparedStylesheet.- Parameters:
pss
- the PreparedStylesheet to be updated- Throws:
XPathException
- if the PreparedStylesheet cannot be updated
-
getAbstractComponents
public java.util.Map<SymbolicName,Component> getAbstractComponents()
-
markNonExportable
public void markNonExportable(java.lang.String message, java.lang.String errorCode)
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
public void export(ExpressionPresenter presenter) throws XPathException
Output the abstract expression tree to the supplied destination.- Parameters:
presenter
- the expression presenter used to display the structure- Throws:
XPathException
-
checkForAbstractComponents
public void checkForAbstractComponents() throws XPathException
- 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()
-
-