Package net.sf.saxon.style
Class PrincipalStylesheetModule
- java.lang.Object
- 
- net.sf.saxon.style.StylesheetModule
- 
- net.sf.saxon.style.PrincipalStylesheetModule
 
 
- 
- All Implemented Interfaces:
- GlobalVariableManager
 - Direct Known Subclasses:
- PrincipalStylesheetModuleEE
 
 public class PrincipalStylesheetModule extends StylesheetModule implements GlobalVariableManager Represents both the stylesheet module at the root of the import tree, that is, the module that includes or imports all the others, and also the XSLT package that has this stylesheet module as its root.This version of the StylesheetPackage class represents a trivial package that is constructed by the system to wrap an ordinary (non-package) stylesheet, as available in XSLT 2.0. A subclass is used for "real" packages, currently available only in Saxon-EE. 
- 
- 
Field Summary- 
Fields inherited from class net.sf.saxon.style.StylesheetModuletopLevel
 
- 
 - 
Constructor SummaryConstructors Constructor Description PrincipalStylesheetModule(XSLPackage sourceElement)Create a PrincipalStylesheetModule
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFixupAction(Action action)Register a callback action to be performed during the fixup phasevoidaddGlobalVariable(GlobalVariable variable)Add a global variable to the collectionvoidaddGlobalVariable(GlobalVariable variable, Visibility visibility)protected voidaddImportedSchema(java.lang.String targetNamespace)protected voidaddNamespaceAlias(ComponentDeclaration node)voidadjustExposedVisibility()Adjust visibility of components by applying xsl:expose rulesbooleancheckAcceptableModeForPackage(XSLTemplate template, Mode mode)Check that it is legitimate to add a given template rule to a given modeprotected voidcheckStreamability(AttributeSet aSet)Check the streamability of an attribute set declared within this stylesheet module.voidcombineAttributeSets(Compilation compilation)Combine all like-named xsl:attribute-set declarations in this package into a single Component, whose body is an AttributeSet object.protected voidcompile(Compilation compilation)Compile the source XSLT stylesheet packageprotected voidcompileError(java.lang.String message, java.lang.String errorCode)Compile time error, specifying an error codeprotected voidcompileError(XPathException error)Report an error with diagnostic informationprotected voidcomplete()voiddeclareXQueryFunction(XQueryFunction function)Declare an imported XQuery functionprotected voidfixup()java.util.PropertiesgatherOutputProperties(StructuredQName formatQName)Create an output properties object representing the xsl:output elements in the stylesheet.AccumulatorRegistrygetAccumulatorManager()Get the class that manages accumulator functionsjava.util.List<ComponentDeclaration>getAttributeSetDeclarations(StructuredQName name)Return all the attribute set declarations in the package having a particular QNameprotected voidgetAttributeSets(StructuredQName name, java.util.List<ComponentDeclaration> list)Get the list of attribute-set declarations associated with a given QName.ComponentDeclarationgetCharacterMap(StructuredQName name)Get a character map, identified by the fingerprint of its name.CharacterMapIndexgetCharacterMapIndex()Get an index of character maps declared using xsl:character-map entries in this packageComponentgetComponent(SymbolicName name)Search the package for a component with a given nameDecimalFormatManagergetDecimalFormatManager()Get the decimal format manager used to manage xsl:decimal-format declarations in this packageGlobalVariablegetEquivalentVariable(Expression select)Get an existing global variable whose initializer is a given expression, if there is one.SourceBindinggetGlobalVariableBinding(StructuredQName qName)Get the global variable or parameter with a given name (taking precedence rules into account).protected java.util.Set<java.lang.String>getImportedSchemaTable()KeyManagergetKeyManager()Get the key manager used to manage xsl:key declarations in this packageNamedTemplategetNamedTemplate(StructuredQName name)Get the named template with a given nameprotected NamespaceBindinggetNamespaceAlias(java.lang.String uri)Get the declared namespace alias for a given namespace URI code if there is one.PrincipalStylesheetModulegetPrincipalStylesheetModule()Get the outermost stylesheet module in a packageRuleManagergetRuleManager()Get the rule manager used to manage modes declared explicitly or implicitly in this packageSlotManagergetSlotManager()XSLModuleRootgetStylesheetDocument(DocumentKey key)Get a module from the cache of stylesheet modulesStylesheetPackagegetStylesheetPackage()Get the stylesheet packageTypeAliasManagergetTypeAliasManager()Get the type alias manager (type aliases are a Saxon extension)protected booleanhasNamespaceAliases()protected voidimportSchemata()Process import-schema declarationsprotected voidindexAttributeSet(ComponentDeclaration decl)Add an attribute set to the indexprotected voidindexFunction(ComponentDeclaration decl)Add a stylesheet function to the indexvoidindexMode(ComponentDeclaration decl)Handle an explicitly-declared modeprotected voidindexNamedTemplate(ComponentDeclaration decl)Add a named template to the indexprotected voidindexVariableDeclaration(ComponentDeclaration decl)Index a global xsl:variable or xsl:param elementprotected booleanisAliasResultNamespace(java.lang.String uri)Determine if a namespace is included in the result-prefix of a namespace-aliasbooleanisDeclaredModes()Ask whether it is required that modes be explicitly declaredprotected booleanisImportedSchema(java.lang.String targetNamespace)Get an imported schema with a given namespacevoidoptimizeTopLevel()voidpreprocess(Compilation compilation)Preprocess does all the processing possible before the source document is available.voidprocessAllAttributes()Process the attributes of every node in the stylesheetvoidputStylesheetDocument(DocumentKey key, XSLStylesheet module)Add a module to the cache of stylesheet modulesvoidsetAccumulatorManager(AccumulatorRegistry accumulatorManager)Set the class that manages accumulator functionsvoidsetNeedsDynamicOutputProperties(boolean b)Say that this stylesheet package needs dynamic output propertiesprotected voidspliceUsePackages(XSLPackage xslpackage, Compilation compilation)Incorporate declarations from used packages- 
Methods inherited from class net.sf.saxon.style.StylesheetModulegetAssociatedStylesheet, getConfiguration, getImporter, getInputTypeAnnotations, getMinImportPrecedence, getPrecedence, getRootElement, getStylesheetElement, loadStylesheet, loadStylesheetModule, setImporter, setInputTypeAnnotations, setMinImportPrecedence, setWasIncluded, spliceIncludes
 
- 
 
- 
- 
- 
Constructor Detail- 
PrincipalStylesheetModulepublic PrincipalStylesheetModule(XSLPackage sourceElement) throws XPathException Create a PrincipalStylesheetModule- Parameters:
- sourceElement- the xsl:package element at the root of the package manifest
- Throws:
- XPathException- if things go wrong
 
 
- 
 - 
Method Detail- 
getComponentpublic Component getComponent(SymbolicName name) Search the package for a component with a given name- Parameters:
- name- the symbolic name of the required component
- Returns:
- the requested component if found, or null otherwise
 
 - 
getPrincipalStylesheetModulepublic PrincipalStylesheetModule getPrincipalStylesheetModule() Get the outermost stylesheet module in a package- Overrides:
- getPrincipalStylesheetModulein class- StylesheetModule
- Returns:
- this module (this class represents both the package and its outermost module)
 
 - 
getStylesheetPackagepublic StylesheetPackage getStylesheetPackage() Get the stylesheet package- Returns:
- the associated stylesheet package
 
 - 
getKeyManagerpublic KeyManager getKeyManager() Get the key manager used to manage xsl:key declarations in this package- Returns:
- the key manager
 
 - 
getDecimalFormatManagerpublic DecimalFormatManager getDecimalFormatManager() Get the decimal format manager used to manage xsl:decimal-format declarations in this package- Returns:
- the decimal format manager
 
 - 
getRuleManagerpublic RuleManager getRuleManager() Get the rule manager used to manage modes declared explicitly or implicitly in this package- Returns:
- the rule manager
 
 - 
isDeclaredModespublic boolean isDeclaredModes() Ask whether it is required that modes be explicitly declared- Returns:
- true if modes referenced within this package must be explicitly declared
 
 - 
addFixupActionpublic void addFixupAction(Action action) Register a callback action to be performed during the fixup phase- Parameters:
- action- the callback action
 
 - 
setNeedsDynamicOutputPropertiespublic void setNeedsDynamicOutputProperties(boolean b) Say that this stylesheet package needs dynamic output properties- Parameters:
- b- true if this stylesheet needs dynamic output properties
 
 - 
getCharacterMapIndexpublic CharacterMapIndex getCharacterMapIndex() Get an index of character maps declared using xsl:character-map entries in this package- Returns:
- the character map index
 
 - 
getTypeAliasManagerpublic TypeAliasManager getTypeAliasManager() Get the type alias manager (type aliases are a Saxon extension)- Returns:
- the type alias manager
 
 - 
declareXQueryFunctionpublic void declareXQueryFunction(XQueryFunction function) throws XPathException Declare an imported XQuery function- Parameters:
- function- the imported function
- Throws:
- XPathException- if an error occurs
 
 - 
putStylesheetDocumentpublic void putStylesheetDocument(DocumentKey key, XSLStylesheet module) Add a module to the cache of stylesheet modules- Parameters:
- key- the key to be used (based on the absolute URI)
- module- the stylesheet document tree corresponding to this absolute URI
 
 - 
getStylesheetDocumentpublic XSLModuleRoot getStylesheetDocument(DocumentKey key) Get a module from the cache of stylesheet modules- Parameters:
- key- the key to be used (based on the absolute URI)
- Returns:
- the stylesheet document tree corresponding to this absolute URI
 
 - 
preprocesspublic void preprocess(Compilation compilation) throws XPathException Preprocess does all the processing possible before the source document is available. It is done once per stylesheet, so the stylesheet can be reused for multiple source documents. The method is called only on the XSLStylesheet element representing the principal stylesheet module- Parameters:
- compilation- the XSLT compilation in progress
- Throws:
- XPathException- if errors are found in the stylesheet
 
 - 
spliceUsePackagesprotected void spliceUsePackages(XSLPackage xslpackage, Compilation compilation) throws XPathException Incorporate declarations from used packages- Parameters:
- xslpackage- the used package
- compilation- this compilation
- Throws:
- XPathException- if any error is detected in the used package
 
 - 
importSchemataprotected void importSchemata() throws XPathExceptionProcess import-schema declarations- Throws:
- XPathException- if errors are detected
 
 - 
processAllAttributespublic void processAllAttributes() throws XPathExceptionProcess the attributes of every node in the stylesheet- Throws:
- XPathException- if static errors are found in the stylesheet
 
 - 
indexFunctionprotected void indexFunction(ComponentDeclaration decl) Add a stylesheet function to the index- Parameters:
- decl- The declaration wrapping an XSLFunction object
 
 - 
indexVariableDeclarationprotected void indexVariableDeclaration(ComponentDeclaration decl) throws XPathException Index a global xsl:variable or xsl:param element- Parameters:
- decl- The Declaration referencing the XSLVariable or XSLParam element
- Throws:
- XPathException- if an error occurs
 
 - 
getGlobalVariableBindingpublic SourceBinding getGlobalVariableBinding(StructuredQName qName) Get the global variable or parameter with a given name (taking precedence rules into account). This will only return global variables declared in the same package where they are used.- Parameters:
- qName- name of the global variable or parameter
- Returns:
- the variable declaration, or null if it does not exist
 
 - 
indexNamedTemplateprotected void indexNamedTemplate(ComponentDeclaration decl) throws XPathException Add a named template to the index- Parameters:
- decl- the declaration of the Template object
- Throws:
- XPathException- if an error occurs
 
 - 
getNamedTemplatepublic NamedTemplate getNamedTemplate(StructuredQName name) Get the named template with a given name- Parameters:
- name- the name of the required template
- Returns:
- the template with the given name, if there is one, or null otherwise. If there are several templates with the same name, the one with highest import precedence is returned. Note that this template may subsequently be overridden in another package, but only by another template with a compatible signature.
 
 - 
indexAttributeSetprotected void indexAttributeSet(ComponentDeclaration decl) throws XPathException Add an attribute set to the index- Parameters:
- decl- the declaration of the attribute set object
- Throws:
- XPathException- if an error occurs
 
 - 
getAttributeSetDeclarationspublic java.util.List<ComponentDeclaration> getAttributeSetDeclarations(StructuredQName name) Return all the attribute set declarations in the package having a particular QName- Parameters:
- name- the name of the required declarations
- Returns:
- the set of declarations having this name, or null if there are none
 
 - 
combineAttributeSetspublic void combineAttributeSets(Compilation compilation) throws XPathException Combine all like-named xsl:attribute-set declarations in this package into a single Component, whose body is an AttributeSet object. The resulting attribute set Components are saved in the StylesheetPackage object.- Parameters:
- compilation- the XSLT compilation in progress
- Throws:
- XPathException- if a failure occurs
 
 - 
checkStreamabilityprotected void checkStreamability(AttributeSet aSet) throws XPathException Check the streamability of an attribute set declared within this stylesheet module. (Null implementation for Saxon-HE).- Parameters:
- aSet- the attribute set to be checked
- Throws:
- XPathException- if the streamability rules are not satisifed
 
 - 
getAttributeSetsprotected void getAttributeSets(StructuredQName name, java.util.List<ComponentDeclaration> list) Get the list of attribute-set declarations associated with a given QName. This is used for xsl:element, xsl:copy, xsl:attribute-set, and on literal result elements- Parameters:
- name- the name of the required attribute set
- list- a list to hold the list of XSLAttributeSet elements in the stylesheet tree.
 
 - 
indexModepublic void indexMode(ComponentDeclaration decl) Handle an explicitly-declared mode- Parameters:
- decl- the declaration of the Mode object
 
 - 
checkAcceptableModeForPackagepublic boolean checkAcceptableModeForPackage(XSLTemplate template, Mode mode) Check that it is legitimate to add a given template rule to a given mode- Parameters:
- template- the template rule
- mode- the mode
- Returns:
- true if all is well, false if the mode cannot be extended (in which case an error will have been reported)
 
 - 
getAccumulatorManagerpublic AccumulatorRegistry getAccumulatorManager() Get the class that manages accumulator functions- Returns:
- the class that manages accumulators. Always null in Saxon-HE
 
 - 
setAccumulatorManagerpublic void setAccumulatorManager(AccumulatorRegistry accumulatorManager) Set the class that manages accumulator functions- Parameters:
- accumulatorManager- the manager of accumulator functions
 
 - 
addNamespaceAliasprotected void addNamespaceAlias(ComponentDeclaration node) 
 - 
getNamespaceAliasprotected NamespaceBinding getNamespaceAlias(java.lang.String uri) Get the declared namespace alias for a given namespace URI code if there is one. If there is more than one, we get the last.- Parameters:
- uri- The uri used in the stylesheet.
- Returns:
- The namespace binding to be used (prefix and uri): return null if no alias is defined
 
 - 
isAliasResultNamespaceprotected boolean isAliasResultNamespace(java.lang.String uri) Determine if a namespace is included in the result-prefix of a namespace-alias- Parameters:
- uri- the namespace URI
- Returns:
- true if an xsl:namespace-alias has been defined for this namespace URI
 
 - 
hasNamespaceAliasesprotected boolean hasNamespaceAliases() 
 - 
gatherOutputPropertiespublic java.util.Properties gatherOutputProperties(StructuredQName formatQName) throws XPathException Create an output properties object representing the xsl:output elements in the stylesheet.- Parameters:
- formatQName- The name of the output format required. If set to null, gathers information for the unnamed output format
- Returns:
- the Properties object containing the details of the specified output format
- Throws:
- XPathException- if a named output format does not exist in the stylesheet
 
 - 
compileprotected void compile(Compilation compilation) throws XPathException Compile the source XSLT stylesheet package- Parameters:
- compilation- the compilation episode
- Throws:
- XPathException- if compilation fails for any reason
 
 - 
optimizeTopLevelpublic void optimizeTopLevel() throws XPathException- Throws:
- XPathException
 
 - 
isImportedSchemaprotected boolean isImportedSchema(java.lang.String targetNamespace) Get an imported schema with a given namespace- Parameters:
- targetNamespace- The target namespace of the required schema. Supply an empty string for the default namespace
- Returns:
- the required Schema, or null if no such schema has been imported
 
 - 
addImportedSchemaprotected void addImportedSchema(java.lang.String targetNamespace) 
 - 
getImportedSchemaTableprotected java.util.Set<java.lang.String> getImportedSchemaTable() 
 - 
getCharacterMappublic ComponentDeclaration getCharacterMap(StructuredQName name) Get a character map, identified by the fingerprint of its name. Search backwards through the stylesheet.- Parameters:
- name- The character map name being sought
- Returns:
- the identified character map, or null if not found
 
 - 
adjustExposedVisibilitypublic void adjustExposedVisibility() throws XPathExceptionAdjust visibility of components by applying xsl:expose rules- Throws:
- XPathException- if this detects an error or inconsistency
 
 - 
compileErrorprotected void compileError(java.lang.String message, java.lang.String errorCode) throws XPathExceptionCompile time error, specifying an error code- Parameters:
- message- the error message
- errorCode- the error code. May be null if not known or not defined
- Throws:
- XPathException- unconditionally
 
 - 
compileErrorprotected void compileError(XPathException error) Report an error with diagnostic information- Parameters:
- error- contains information about the error
 
 - 
fixupprotected void fixup() throws XPathException- Throws:
- XPathException
 
 - 
completeprotected void complete() throws XPathException- Throws:
- XPathException
 
 - 
getSlotManagerpublic SlotManager getSlotManager() 
 - 
getEquivalentVariablepublic GlobalVariable getEquivalentVariable(Expression select) Description copied from interface:GlobalVariableManagerGet an existing global variable whose initializer is a given expression, if there is one. Note that this depends on the logic for detecting equivalence of expressions, which is necessarily approximate. Expressions with dependencies on the static context should never be considered equivalent. If no equivalent global variable is found, return null. An implementation can always return null if it wants to avoid a lengthy search.- Specified by:
- getEquivalentVariablein interface- GlobalVariableManager
- Parameters:
- select- the expression to which the variable is bound
- Returns:
- an existing global variable with the same select expression, if one can be found; otherwise null.
 
 - 
addGlobalVariablepublic void addGlobalVariable(GlobalVariable variable) Description copied from interface:GlobalVariableManagerAdd a global variable to the collection- Specified by:
- addGlobalVariablein interface- GlobalVariableManager
- Parameters:
- variable- the variable to be added
 
 - 
addGlobalVariablepublic void addGlobalVariable(GlobalVariable variable, Visibility visibility) 
 
- 
 
-