## net.sf.saxon.style
Class PrincipalStylesheetModule

    java.lang.Object
      net.sf.saxon.style.StylesheetModule
          net.sf.saxon.style.PrincipalStylesheetModule

    public class PrincipalStylesheetModule

extends StylesheetModule

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`

Constructor Summary
`PrincipalStylesheetModule(XSLStylesheet sourceElement, int precedence)`

Method Summary
`protected 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 rules
`int` `allocateUniqueParameterNumber(StructuredQName qName)` Allocate a unique number to a local parameter name.
`protected void` `compileError(String message, String errorCode)` Compile time error, specifying an error code
`protected void` `compileError(XPathException error)` Report an error with diagnostic information
`void` `compileStylesheet()` Compile the stylesheet to create an executable.
`FunctionLibraryList` `createFunctionLibrary()` Create the function library
`void` `declareXQueryFunction(XQueryFunction function)` Declare an imported XQuery function
`protected StringCollator` `findCollation(String name, String baseURI)` Find a named collation.
`Properties` `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.
`Declaration` `getCharacterMap(StructuredQName name)` Get a character map, identified by the fingerprint of its name.
`CollationMap` `getCollationMap()` Get the collation map
`protected XSLFunction` `getFunction(StructuredQName name, int arity)` Get the function with a given name and arity
`protected Declaration` `getFunctionDeclaration(StructuredQName name, int arity)`
`FunctionLibrary` `getFunctionLibrary()` Get the function library.
`XSLVariableDeclaration` `getGlobalVariable(StructuredQName qName)` Get the global variable or parameter with a given name (taking precedence rules into account)
`protected HashSet<String>` `getImportedSchemaTable()`
`XSLTemplate` `getNamedTemplate(StructuredQName name)` Get the named template with a given name
`protected int` `getNamespaceAlias(short uriCode)` Get the declared namespace alias for a given namespace URI code if there is one.
`PreparedStylesheet` `getPreparedStylesheet()`
`PrincipalStylesheetModule` `getPrincipalStylesheetModule()`
`protected StripSpaceRules` `getStripperRules()` Get the rules determining which nodes are to be stripped from the tree
`XSLStylesheet` `getStylesheetDocument(DocumentURI key)` Get a module from the cache
`String` `getVersion()` Get the value of the version attribute on the xsl:stylesheet element of the principal stylesheet module
`protected boolean` `hasNamespaceAliases()`
`protected void` `indexFunction(Declaration decl)` Add a stylesheet function to the index
`protected void` `indexNamedTemplate(Declaration decl)` Add a named template to the index
`protected void` `indexVariableDeclaration(Declaration decl)` Index a global xsl:variable or xsl:param element
`protected boolean` `isAliasResultNamespace(short uriCode)` Determine if a namespace is included in the result-prefix of a namespace-alias
`protected boolean` `isImportedSchema(String targetNamespace)` Get an imported schema with a given namespace
`void` `preprocess()` Preprocess does all the processing possible before the source document is available.
`void` `processAllAttributes()` Process the attributes of every node in the stylesheet
`protected void` `putFunction(Declaration decl)`
`void` `putStylesheetDocument(DocumentURI key, XSLStylesheet module)` Add a module to the cache
`void` `setCollation(String name, StringCollator collation)` Register a named collation (actually a StringCollator)
`void` `setNeedsDynamicOutputProperties(boolean b)` Say that this stylesheet needs dynamic output properties
`void` `setPreparedStylesheet(PreparedStylesheet preparedStylesheet)`
`void` `setVersion(String version)` Set the value of the version attribute on the xsl:stylesheet element of the principal stylesheet module
`boolean` `stripsWhitespace()` Determine whether this stylesheet does any whitespace stripping

Methods inherited from class net.sf.saxon.style.StylesheetModule
`getImporter, getInputTypeAnnotations, getMinImportPrecedence, getPrecedence, getSourceElement, setImporter, setInputTypeAnnotations, setMinImportPrecedence, setWasIncluded, spliceIncludes`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PrincipalStylesheetModule

    public PrincipalStylesheetModule(XSLStylesheet sourceElement,
                                     int precedence)

Method Detail

### setPreparedStylesheet

    public void setPreparedStylesheet(PreparedStylesheet preparedStylesheet)

### getPreparedStylesheet

    public PreparedStylesheet getPreparedStylesheet()

### getPrincipalStylesheetModule

    public PrincipalStylesheetModule getPrincipalStylesheetModule()

  Overrides:
    `getPrincipalStylesheetModule` in class `StylesheetModule`

### createFunctionLibrary

    public FunctionLibraryList createFunctionLibrary()

  Create the function library

### getFunctionLibrary

    public FunctionLibrary getFunctionLibrary()

  Get the function library. Available only on the principal stylesheet module

  Returns:
    the function library

### declareXQueryFunction

    public void declareXQueryFunction(XQueryFunction function)
                               throws XPathException

  Declare an imported XQuery function

  Parameters:
    `function` - the imported function
  Throws:
    `XPathException`

### putStylesheetDocument

    public void putStylesheetDocument(DocumentURI key,
                                      XSLStylesheet module)

  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

    public XSLStylesheet getStylesheetDocument(DocumentURI key)

  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

    public void preprocess()
                    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

  Throws:
    `XPathException`

### processAllAttributes

    public void processAllAttributes()
                              throws XPathException

  Process the attributes of every node in the stylesheet

  Throws:
    `XPathException`

### indexFunction

    protected void indexFunction(Declaration decl)
                          throws XPathException

  Add a stylesheet function to the index

  Parameters:
    `decl` - The declaration wrapping an XSLFunction object
  Throws:
    `XPathException`

### getFunctionDeclaration

    protected Declaration getFunctionDeclaration(StructuredQName name,
                                                 int arity)

### getFunction

    protected XSLFunction getFunction(StructuredQName name,
                                      int arity)

  Get the function with a given name and arity

  Parameters:
    `name` - the name of the function
    `arity` - the arity of the function, or -1 if any arity will do
  Returns:
    the requested function, or null if none can be found

### putFunction

    protected void putFunction(Declaration decl)

### indexVariableDeclaration

    protected void indexVariableDeclaration(Declaration decl)
                                     throws XPathException

  Index a global xsl:variable or xsl:param element

  Parameters:
    `decl` - The Declaration referencing the XSLVariable or XSLParam element
  Throws:
    `XPathException`

### getGlobalVariable

    public XSLVariableDeclaration getGlobalVariable(StructuredQName qName)

  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

    public int allocateUniqueParameterNumber(StructuredQName qName)

  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

    protected void indexNamedTemplate(Declaration decl)
                               throws XPathException

  Add a named template to the index

  Parameters:
    `decl` - the declaration of the Template object
  Throws:
    `XPathException`

### getNamedTemplate

    public XSLTemplate 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.

### addNamespaceAlias

    protected void addNamespaceAlias(Declaration node)

### getNamespaceAlias

    protected int getNamespaceAlias(short uriCode)

  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:
    `uriCode` - The code of the uri used in the stylesheet.
  Returns:
    The namespace code to be used (prefix in top half, uri in bottom half): return -1 if no alias is defined

### isAliasResultNamespace

    protected boolean isAliasResultNamespace(short uriCode)

  Determine if a namespace is included in the result-prefix of a namespace-alias

  Parameters:
    `uriCode` - the namepool code of the URI
  Returns:
    true if an xsl:namespace-alias has been defined for this namespace URI

### hasNamespaceAliases

    protected boolean hasNamespaceAliases()

### getCollationMap

    public CollationMap getCollationMap()

  Get the collation map

  Returns:
    the CollationMap

### setCollation

    public void setCollation(String name,
                             StringCollator collation)

  Register a named collation (actually a StringCollator)

  Parameters:
    `name` - the name of the collation
    `collation` - the StringCollator that implements this collation

### findCollation

    protected StringCollator findCollation(String name,
                                           String baseURI)

  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 required
  Returns:
    null if the collation is not found

### gatherOutputProperties

    public 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

### compileStylesheet

    public void compileStylesheet()
                           throws XPathException

  Compile the stylesheet to create an executable.

  Throws:
    `XPathException`

### isImportedSchema

    protected boolean isImportedSchema(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

### addImportedSchema

    protected void addImportedSchema(String targetNamespace)

### getImportedSchemaTable

    protected HashSet<String> 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 set
    `list` - 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`

### stripsWhitespace

    public boolean stripsWhitespace()

  Determine whether this stylesheet does any whitespace stripping

  Returns:
    true if this stylesheet strips whitespace from source documents

### getStripperRules

    protected StripSpaceRules getStripperRules()

  Get the rules determining which nodes are to be stripped from the tree

  Returns:
    the Mode object holding the whitespace stripping rules. The stripping rules defined in xsl:strip-space are managed in the same way as template rules, hence the use of a special Mode object

### setVersion

    public void setVersion(String version)

  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

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

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

### 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

    protected void compileError(String message,
                                String errorCode)
                         throws XPathException

  Compile 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`

### compileError

    protected void compileError(XPathException error)
                         throws XPathException

  Report an error with diagnostic information

  Parameters:
    `error` - contains information about the error
  Throws:
    `XPathException` - always, after reporting the error to the ErrorListener

Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.