Class XSLStylesheet

All Implemented Interfaces:
Source, SourceLocator, LocationProvider, SaxonLocator, Container, FingerprintedNode, Item, NodeInfo, ValueRepresentation, InstructionInfo, Locator

public class XSLStylesheet extends StyleElement
An xsl:stylesheet or xsl:transform element in the stylesheet.
Note this element represents a stylesheet module, not necessarily the whole stylesheet.
  • Field Details

  • Constructor Details

    • XSLStylesheet

      public XSLStylesheet()
  • Method Details

    • setPreparedStylesheet

      public void setPreparedStylesheet(PreparedStylesheet sheet)
      Create link to the owning PreparedStylesheet object
    • getPreparedStylesheet

      public PreparedStylesheet getPreparedStylesheet()
      Get the owning PreparedStylesheet object
      Overrides:
      getPreparedStylesheet in class StyleElement
      Returns:
      the PreparedStylesheet to which this stylesheet element belongs
    • getExecutable

      public Executable getExecutable()
      Get the run-time Executable object
      Specified by:
      getExecutable in interface Container
      Overrides:
      getExecutable in class StyleElement
    • getFunctionLibrary

      public FunctionLibrary getFunctionLibrary()
      Get the function library. Available only on the principal stylesheet module
    • getLocationMap

      public LocationMap getLocationMap()
      Get the locationMap object
    • getTargetNamePool

      public NamePool getTargetNamePool()
      Get the namepool to be used at run-time, this namepool holds the names used in all XPath expressions and patterns
      Overrides:
      getTargetNamePool in class StyleElement
    • getRuleManager

      public RuleManager getRuleManager()
      Get the RuleManager which handles template rules
    • getStripperRules

      protected Mode getStripperRules()
      Get the rules determining which nodes are to be stripped from the tree
    • stripsWhitespace

      public boolean stripsWhitespace()
      Determine whether this stylesheet does any whitespace stripping
    • getKeyManager

      public KeyManager getKeyManager()
      Get the KeyManager which handles key definitions
    • getDecimalFormatManager

      public DecimalFormatManager getDecimalFormatManager()
      Get the DecimalFormatManager which handles decimal-format definitions
    • getCollationMap

      public CollationMap getCollationMap()
      Get the collation map
    • setCollation

      public void setCollation(String name, Comparator collation)
      Register a named collation (actually a Comparator)
    • findCollation

      protected Comparator findCollation(String name)
      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; null indicates that the default collation is required
      Returns:
      null if the collation is not found
    • getDefaultCollationName

      public String getDefaultCollationName()
      Get the name of the default collation
      Overrides:
      getDefaultCollationName in class StyleElement
    • getCharacterMap

      public XSLCharacterMap getCharacterMap(int fingerprint)
      Get a character map, identified by the fingerprint of its name. Search backwards through the stylesheet.
      Parameters:
      fingerprint - The fingerprint of the character map name, in the target namepool.
      Returns:
      the identified character map, or null if not found
    • setPrecedence

      public void setPrecedence(int prec)
      Set the import precedence of this stylesheet
    • getPrecedence

      public int getPrecedence()
      Get the import precedence of this stylesheet
      Overrides:
      getPrecedence in class StyleElement
    • getMinImportPrecedence

      public int getMinImportPrecedence()
      Get the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one
    • setMinImportPrecedence

      public void setMinImportPrecedence(int precedence)
      Set the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one
    • setImporter

      public void setImporter(XSLStylesheet importer)
      Set the StyleSheet that included or imported this one.
    • getImporter

      public XSLStylesheet getImporter()
      Get the StyleSheet that included or imported this one.
      Returns:
      null if this is the principal stylesheet
    • setWasIncluded

      public void setWasIncluded()
      Indicate that this stylesheet was included (by its "importer") using an xsl:include statement as distinct from xsl:import
    • getTopLevel

      public List getTopLevel()
      Get the top level elements in this stylesheet, after applying include/import
    • allocateGlobalSlot

      public int allocateGlobalSlot(int fingerprint)
      Allocate a slot number for a global variable or parameter
    • allocatePatternSlots

      public void allocatePatternSlots(int n)
      Ensure there is enough space for local variables or parameters when evaluating the match pattern of template rules
    • prepareAttributes

      public void prepareAttributes() throws XPathException
      Prepare the attributes on the stylesheet element
      Specified by:
      prepareAttributes in class StyleElement
      Throws:
      XPathException
    • getDefaultValidation

      public int getDefaultValidation()
      Get the value of the default validation attribute
    • getInputTypeAnnotationsAttribute

      public int getInputTypeAnnotationsAttribute() throws XPathException
      Get the value of the input-type-annotations attribute, for this module alone. The value is an or-ed combination of the two bits ANNOTATION_STRIP and ANNOTATION_PRESERVE
      Throws:
      XPathException
    • getInputTypeAnnotations

      public int getInputTypeAnnotations()
      Get the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules. The value is an or-ed combination of the two bits ANNOTATION_STRIP and ANNOTATION_PRESERVE
    • setInputTypeAnnotations

      public void setInputTypeAnnotations(int annotations) throws XPathException
      Set the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules. The value is an or-ed combination of the two bits ANNOTATION_STRIP and ANNOTATION_PRESERVE
      Throws:
      XPathException
    • allowsAllBuiltInTypes

      public boolean allowsAllBuiltInTypes()
      Determine whether the use of non-primitive built-in types has been enabled for this stylesheet (This is relevant only for Saxon-B: such types are always permitted in Saxon-SA)
    • 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
    • validate

      public void validate() throws XPathException
      Validate this element
      Overrides:
      validate in class StyleElement
      Throws:
      XPathException
    • 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
    • spliceIncludes

      public void spliceIncludes() throws XPathException
      Process xsl:include and xsl:import elements.
      Throws:
      XPathException
    • hasNamespaceAliases

      protected boolean hasNamespaceAliases()
    • processAllAttributes

      public void processAllAttributes() throws XPathException
      Process the attributes of every node in the stylesheet
      Overrides:
      processAllAttributes in class StyleElement
      Throws:
      XPathException
    • getGlobalVariable

      public XSLVariableDeclaration getGlobalVariable(int fingerprint)
      Get the global variable or parameter with a given fingerprint (taking precedence rules into account)
    • setNeedsDynamicOutputProperties

      public void setNeedsDynamicOutputProperties(boolean b)
      Set that this stylesheet needs dynamic output properties
    • gatherOutputProperties

      public Properties gatherOutputProperties(int fingerprint) throws XPathException
      Create an output properties object representing the xsl:output elements in the stylesheet.
      Parameters:
      fingerprint - The name of the output format required. If set to -1, 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
    • declareXQueryFunction

      protected void declareXQueryFunction(XQueryFunction function) throws XPathException
      Declare an imported XQuery function
      Throws:
      XPathException
    • declareJavaClass

      protected void declareJavaClass(String uri, Class theClass)
      Declare a URI that maps to a Java class containing extension functions
    • 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 getImportedSchemaTable()
    • compileStylesheet

      public Executable compileStylesheet() throws XPathException
      Compile the stylesheet to create an executable.
      Throws:
      XPathException
    • compile

      public Expression compile(Executable exec)
      Dummy compile() method to satisfy the interface
      Specified by:
      compile in class StyleElement
      Returns:
      either a ComputedExpression, or null. The value null is returned when compiling an instruction that returns a no-op, or when compiling a top-level object such as an xsl:template that compiles into something other than an instruction.