Package net.sf.saxon.style
Class PrincipalStylesheetModule
java.lang.Object
net.sf.saxon.style.StylesheetModule
net.sf.saxon.style.PrincipalStylesheetModule
Represents the stylesheet module at the root of the import tree, that is, the module
that includes or imports all the others. Note that this object is present at compile time only,
unlike the Executable, which also exists at run-time.
-
Field Summary
Fields inherited from class net.sf.saxon.style.StylesheetModule
topLevel, wasIncluded
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addImportedSchema
(String targetNamespace) protected void
addNamespaceAlias
(Declaration node) void
allocatePatternSlots
(int n) Ensure there is enough space for local variables or parameters when evaluating the match pattern of template rulesint
Allocate a unique number to a local parameter name.protected void
compileError
(String message, String errorCode) Compile time error, specifying an error codeprotected void
compileError
(XPathException error) Report an error with diagnostic informationvoid
Compile the stylesheet to create an executable.Create the function libraryvoid
declareXQueryFunction
(XQueryFunction function) Declare an imported XQuery functionfindCollation
(String name, String baseURI) Find a named collation.gatherOutputProperties
(StructuredQName formatQName) Create an output properties object representing the xsl:output elements in the stylesheet.protected boolean
getAttributeSets
(StructuredQName name, List<Declaration> list) Get the list of attribute-set declarations associated with a given QName.Get a character map, identified by the fingerprint of its name.Get the collation mapprotected XSLFunction
getFunction
(StructuredQName name, int arity) Get the function with a given name and arityprotected Declaration
getFunctionDeclaration
(StructuredQName name, int arity) Get the function library.getGlobalVariable
(StructuredQName qName) Get the global variable or parameter with a given name (taking precedence rules into account)Get the named template with a given nameprotected NamespaceBinding
getNamespaceAlias
(String uri) Get the declared namespace alias for a given namespace URI code if there is one.Get a module from the cacheGet the value of the version attribute on the xsl:stylesheet element of the principal stylesheet moduleprotected boolean
protected void
indexFunction
(Declaration decl) Add a stylesheet function to the indexprotected void
Add a named template to the indexprotected void
Index a global xsl:variable or xsl:param elementprotected boolean
Determine if a namespace is included in the result-prefix of a namespace-aliasprotected boolean
isImportedSchema
(String targetNamespace) Get an imported schema with a given namespacevoid
Preprocess does all the processing possible before the source document is available.void
Process the attributes of every node in the stylesheetprotected void
putFunction
(Declaration decl) void
putStylesheetDocument
(DocumentURI key, XSLStylesheet module) Add a module to the cachevoid
setCollation
(String name, StringCollator collation) Register a named collation (actually a StringCollator)void
setNeedsDynamicOutputProperties
(boolean b) Say that this stylesheet needs dynamic output propertiesvoid
setPreparedStylesheet
(PreparedStylesheet preparedStylesheet) void
setVersion
(String version) Set the value of the version attribute on the xsl:stylesheet element of the principal stylesheet moduleboolean
Determine whether this stylesheet does any whitespace strippingMethods inherited from class net.sf.saxon.style.StylesheetModule
getImporter, getInputTypeAnnotations, getMinImportPrecedence, getPrecedence, getSourceElement, setImporter, setInputTypeAnnotations, setMinImportPrecedence, setWasIncluded, spliceIncludes
-
Constructor Details
-
PrincipalStylesheetModule
-
-
Method Details
-
setPreparedStylesheet
-
getPreparedStylesheet
-
getPrincipalStylesheetModule
- Overrides:
getPrincipalStylesheetModule
in classStylesheetModule
-
createFunctionLibrary
Create the function library- Returns:
- the resulting function library
-
getFunctionLibrary
Get the function library. Available only on the principal stylesheet module- Returns:
- the function library
-
declareXQueryFunction
Declare an imported XQuery function- Parameters:
function
- the imported function- Throws:
XPathException
- if an error occurs
-
putStylesheetDocument
Add a module to the cache- Parameters:
key
- the key to be used (based on the absolute URI)module
- the stylesheet document tree corresponding to this absolute URI
-
getStylesheetDocument
Get a module from the cache- Parameters:
key
- the key to be used (based on the absolute URI)- Returns:
- the stylesheet document tree corresponding to this absolute URI
-
preprocess
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- Throws:
XPathException
- if errors are found in the stylesheet
-
processAllAttributes
Process the attributes of every node in the stylesheet- Throws:
XPathException
- if static errors are found in the stylesheet
-
indexFunction
Add a stylesheet function to the index- Parameters:
decl
- The declaration wrapping an XSLFunction object- Throws:
XPathException
- if errors are found
-
getFunctionDeclaration
-
getFunction
Get the function with a given name and arity- Parameters:
name
- the name of the functionarity
- the arity of the function, or -1 if any arity will do- Returns:
- the requested function, or null if none can be found
-
putFunction
-
indexVariableDeclaration
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
-
getGlobalVariable
Get the global variable or parameter with a given name (taking precedence rules into account)- Parameters:
qName
- name of the global variable or parameter- Returns:
- the variable declaration, or null if it does not exist
-
allocateUniqueParameterNumber
Allocate a unique number to a local parameter name. This should only be called on the principal stylesheet module.- Parameters:
qName
- the local parameter name- Returns:
- an integer that uniquely identifies this parameter name within the stylesheet
-
indexNamedTemplate
Add a named template to the index- Parameters:
decl
- the declaration of the Template object- Throws:
XPathException
- if an error occurs
-
getNamedTemplate
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.
-
addNamespaceAlias
-
getNamespaceAlias
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
-
isAliasResultNamespace
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
-
hasNamespaceAliases
protected boolean hasNamespaceAliases() -
getCollationMap
Get the collation map- Returns:
- the CollationMap
-
setCollation
Register a named collation (actually a StringCollator)- Parameters:
name
- the name of the collationcollation
- the StringCollator that implements this collation
-
findCollation
Find a named collation. Note this method should only be used at compile-time, before declarations have been pre-processed. After that time, use getCollation().- Parameters:
name
- identifies the name of the collation requiredbaseURI
- the base URI to be used for resolving the collation name if it is relative- Returns:
- null if the collation is not found
-
gatherOutputProperties
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
-
compileStylesheet
Compile the stylesheet to create an executable.- Throws:
XPathException
- if compilation fails for any reason
-
isImportedSchema
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
-
addImportedSchema
-
getImportedSchemaTable
-
getAttributeSets
protected boolean getAttributeSets(StructuredQName name, List<Declaration> list) throws XPathException 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 setlist
- a list to hold the list of XSLAttributeSet elements in the stylesheet tree.- Returns:
- true if any declarations were found and added to the list; false if none were found
- Throws:
XPathException
- if an error occurs
-
stripsWhitespace
public boolean stripsWhitespace()Determine whether this stylesheet does any whitespace stripping- Returns:
- true if this stylesheet strips whitespace from source documents
-
setVersion
Set the value of the version attribute on the xsl:stylesheet element of the principal stylesheet module- Parameters:
version
- the value of the version attribute
-
getVersion
Get the value of the version attribute on the xsl:stylesheet element of the principal stylesheet module- Returns:
- the value of the version attribute
-
setNeedsDynamicOutputProperties
public void setNeedsDynamicOutputProperties(boolean b) Say that this stylesheet needs dynamic output properties- Parameters:
b
- true if this stylesheet needs dynamic output properties
-
getCharacterMap
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
-
allocatePatternSlots
public void allocatePatternSlots(int n) Ensure there is enough space for local variables or parameters when evaluating the match pattern of template rules- Parameters:
n
- the number of slots to be allocated
-
compileError
Compile time error, specifying an error code- Parameters:
message
- the error messageerrorCode
- the error code. May be null if not known or not defined- Throws:
XPathException
- unconditionally
-
compileError
Report an error with diagnostic information- Parameters:
error
- contains information about the error- Throws:
XPathException
- unconditionally, after reporting the error to the ErrorListener
-