net.sf.saxon.style
Class XSLStyleSheet

java.lang.Object
  extended by net.sf.saxon.om.AbstractNode
      extended by net.sf.saxon.tree.NodeImpl
          extended by net.sf.saxon.tree.ParentNodeImpl
              extended by net.sf.saxon.tree.ElementImpl
                  extended by net.sf.saxon.tree.ElementWithAttributes
                      extended by net.sf.saxon.style.StyleElement
                          extended by net.sf.saxon.style.XSLStyleSheet
All Implemented Interfaces:
DOMLocator, Source, SourceLocator, Item, NodeInfo, Element, NamedNodeMap, Node, 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 Summary
 
Fields inherited from class net.sf.saxon.style.StyleElement
defaultXPathNamespace, extensionNamespaces, REPORT_ALWAYS, REPORT_IF_INSTANTIATED, REPORT_UNLESS_FORWARDS_COMPATIBLE, reportingCircumstances, staticContext, validationError, version
 
Fields inherited from class net.sf.saxon.tree.ElementWithAttributes
attributeList, namespaceList
 
Fields inherited from class net.sf.saxon.tree.ElementImpl
nameCode, root
 
Fields inherited from class net.sf.saxon.tree.ParentNodeImpl
sequence
 
Fields inherited from class net.sf.saxon.tree.NodeImpl
index, parent
 
Fields inherited from class net.sf.saxon.om.AbstractNode
NODE_LETTER
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES
 
Constructor Summary
XSLStyleSheet()
           
 
Method Summary
protected  void addImportedSchema(String targetNamespace)
           
 void allocateLocalSlots(int n)
          Ensure there is enough space for local variables or parameters in any template
 int allocateSlotNumber()
          Allocate a slot number for a global variable or parameter
protected  XQueryFunction bindXQueryFunction(int fingerprint)
          Get an imported XQuery function with a given name, if there is one
 Instruction compile()
          Compile the stylesheet to create an executable.
protected  void declareXQueryFunction(XQueryFunction function)
          Declare an imported XQuery function
protected  Comparator findCollation(String name)
          Find a named collation.
 Properties gatherOutputProperties(int fingerprint)
          Create an output properties object representing the xsl:output elements in the stylesheet.
 XSLCharacterMap getCharacterMap(int fingerprint)
          Get a character map, identified by the fingerprint of its name.
 DecimalFormatManager getDecimalFormatManager()
          Get the DecimalFormatManager which handles decimal-format definitions
 String getDefaultCollationName()
          Get the name of the default collation
 int getDefaultValidation()
          Get the value of the default validation attribute
 Class getExternalJavaClass(String uri)
          Get a Java class for a given namespace URI, if possible.
 XSLVariableDeclaration getGlobalVariable(int fingerprint)
          Get the global variable or parameter with a given fingerprint (taking precedence rules into account)
 XSLStyleSheet getImporter()
          Get the StyleSheet that included or imported this one.
 KeyManager getKeyManager()
          Get the KeyManager which handles key definitions
 int getMinImportPrecedence()
          Get the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one
protected  int getModuleNumber(String module)
          Get the index number of a particular stylesheet module.
protected  int getNamespaceAlias(short uriCode)
          Get the declared namespace alias for a given namespace URI code if there is one.
 int getPrecedence()
          Get the import precedence of this stylesheet
 PreparedStyleSheet getPreparedStyleSheet()
          Get the owning PreparedStyleSheet object
 RuleManager getRuleManager()
          Get the RuleManager which handles template rules
protected  Mode getStripperRules()
          Get the rules determining which nodes are to be stripped from the tree
 NamePool getTargetNamePool()
          Get the namepool to be used at run-time, this namepool holds the names used in all XPath expressions and patterns
 List getTopLevel()
          Get the top level elements in this stylesheet, after applying include/import
protected  boolean hasNamespaceAliases()
           
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 prepareAttributes()
          Prepare the attributes on the stylesheet element
 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  int putModuleNumber(String module)
          Add a stylesheet module to the list of modules if it is not already there, returning its integer code.
 void setCollation(String name, Comparator collation, boolean isDefault)
          Register a named collation (actually a Comparator)
 void setImporter(XSLStyleSheet importer)
          Set the StyleSheet that included or imported this one.
 void setMinImportPrecedence(int precedence)
          Set the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one
 void setPrecedence(int prec)
          Set the import precedence of this stylesheet
 void setPreparedStyleSheet(PreparedStyleSheet sheet)
          Create link to the owning PreparedStyleSheet object
 void setWasIncluded()
          Indicate that this stylesheet was included (by its "importer") using an xsl:include statement as distinct from xsl:import
 void spliceIncludes()
          Process xsl:include and xsl:import elements.
 boolean stripsWhitespace()
          Determine whether this stylesheet does any whitespace stripping
 void validate()
          Validate this element
 
Methods inherited from class net.sf.saxon.style.StyleElement
allocateSlots, backwardsCompatibleModeIsEnabled, bindVariable, checkEmpty, checkTopLevel, checkUnknownAttribute, checkWithinTemplate, compileChildren, compileError, compileError, compileWarning, definesExcludedNamespace, definesExtensionElement, fallbackProcessing, fixupReferences, forwardsCompatibleModeIsEnabled, getAttributeSets, getAttributeValue, getCommonChildItemType, getConfiguration, getContainingStyleSheet, getContextItemType, getDefaultXPathNamespace, getLastChildInstruction, getLineNumber, getOwningProcedure, getPrincipalStyleSheet, getReturnedItemType, getSchemaType, getStyleSheetFunction, getTypeAnnotation, getURIForPrefix, getVariableBinding, getVersion, getWithParamInstructions, isExcludedNamespace, isExtensionNamespace, isInstruction, issueWarning, issueWarning, isTopLevel, makeAttributeValueTemplate, makeExpression, makeNameCode, makeNamespaceContext, makePattern, makeSequenceType, makeSortKeys, markTailCalls, mayContainFallback, mayContainTemplateBody, postValidate, processAttributes, processDefaultXPathNamespaceAttribute, processExcludedNamespaces, processExtensionElementAttribute, processVersionAttribute, reportAbsence, setLineNumber, setValidationError, substituteFor, typeCheck, typeCheck, validateChildren, validateSubtree
 
Methods inherited from class net.sf.saxon.tree.ElementWithAttributes
addNamespaceNodes, copy, getAttribute, getAttributeList, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getAttributeValue, getLength, getNamedItem, getNamedItemNS, getNamespaceCodes, getPrefixForURI, getURICodeForPrefix, hasAttribute, hasAttributeNS, hasAttributes, initialise, item, outputNamespaceNodes, removeAttribute, removeAttributeNode, removeAttributeNS, removeNamedItem, removeNamedItemNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setNamedItem, setNamedItemNS, setNamespaceDeclarations
 
Methods inherited from class net.sf.saxon.tree.ElementImpl
generateId, getBaseURI, getDocumentRoot, getNameCode, getNodeKind, getRoot, getSystemId, setNameCode, setSystemId
 
Methods inherited from class net.sf.saxon.tree.ParentNodeImpl
addChild, compact, enumerateChildren, getFirstChild, getLastChild, getNodeValue, getNthChild, getSequenceNumber, getStringValue, hasChildNodes, useChildrenArray
 
Methods inherited from class net.sf.saxon.tree.NodeImpl
compareOrder, copy, getDisplayName, getDocumentElement, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getURI, isSameNode, iterateAxis, iterateAxis
 
Methods inherited from class net.sf.saxon.om.AbstractNode
appendChild, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getChildNodes, getColumnNumber, getData, getDoctype, getDocumentNumber, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getLocalName, getName, getNamespaceURI, getNodeName, getNodeType, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSpecified, getTagName, getTypeAnnotation, getTypedValue, getValue, importNode, insertBefore, insertData, isSupported, normalize, removeChild, replaceChild, replaceData, setData, setNodeValue, setPrefix, setValue, splitText, substringData, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.Locator
getColumnNumber, getPublicId, getSystemId
 
Methods inherited from interface org.w3c.dom.Element
getElementsByTagName, getElementsByTagNameNS, getSchemaTypeInfo, getTagName, setIdAttribute, setIdAttributeNode, setIdAttributeNS
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Constructor Detail

XSLStyleSheet

public XSLStyleSheet()
Method Detail

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

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

putModuleNumber

protected int putModuleNumber(String module)
Add a stylesheet module to the list of modules if it is not already there, returning its integer code.


getModuleNumber

protected int getModuleNumber(String module)
Get the index number of a particular stylesheet module.

Throws:
NullPointerException - if not found

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


setCollation

public void setCollation(String name,
                         Comparator collation,
                         boolean isDefault)
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


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


allocateSlotNumber

public int allocateSlotNumber()
Allocate a slot number for a global variable or parameter


allocateLocalSlots

public void allocateLocalSlots(int n)
Ensure there is enough space for local variables or parameters in any template


prepareAttributes

public void prepareAttributes()
                       throws TransformerConfigurationException
Prepare the attributes on the stylesheet element

Specified by:
prepareAttributes in class StyleElement
Throws:
TransformerConfigurationException

getDefaultValidation

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


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 TransformerConfigurationException
Validate this element

Overrides:
validate in class StyleElement
Throws:
TransformerConfigurationException

preprocess

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

Throws:
TransformerConfigurationException

spliceIncludes

public void spliceIncludes()
                    throws TransformerConfigurationException
Process xsl:include and xsl:import elements.

Throws:
TransformerConfigurationException

hasNamespaceAliases

protected boolean hasNamespaceAliases()

processAllAttributes

public void processAllAttributes()
                          throws TransformerConfigurationException
Process the attributes of every node in the stylesheet

Overrides:
processAllAttributes in class StyleElement
Throws:
TransformerConfigurationException

getGlobalVariable

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


gatherOutputProperties

public Properties gatherOutputProperties(int fingerprint)
                                  throws TransformerConfigurationException
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:
TransformerConfigurationException - if a named output format does not exist in the stylesheet

getExternalJavaClass

public Class getExternalJavaClass(String uri)
Get a Java class for a given namespace URI, if possible.

Returns:
the Class referred to by the URI (as a Class object), or null if none is found.

declareXQueryFunction

protected void declareXQueryFunction(XQueryFunction function)
Declare an imported XQuery function


bindXQueryFunction

protected XQueryFunction bindXQueryFunction(int fingerprint)
Get an imported XQuery function with a given name, if there is one

Returns:
the XQueryFunction object if it exists, or null otherwise

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)

compile

public Instruction compile()
                    throws TransformerConfigurationException
Compile the stylesheet to create an executable.

Specified by:
compile in class StyleElement
Returns:
either an Instruction, or null (indicating a no-op).
Throws:
TransformerConfigurationException