com.icl.saxon.style

Class StyleElement

Implemented Interfaces:
DOMLocator, Element, Locator, NamedNodeMap, Node, NodeInfo, Source, SourceLocator
Known Direct Subclasses:
AbsentExtensionElement, LiteralResultElement, SAXONDoctype, SAXONEntityRef, SAXONFunction, SAXONItem, SAXONPreview, SAXONWhile, SQLClose, SQLConnect, SQLInsert, XSLApplyImports, XSLApplyTemplates, XSLAttributeSet, XSLCallTemplate, XSLChoose, XSLCopy, XSLCopyOf, XSLDecimalFormat, XSLElement, XSLFallback, XSLForEach, XSLGeneralIncorporate, XSLGeneralOutput, XSLGeneralVariable, XSLIf, XSLKey, XSLMessage, XSLNamespaceAlias, XSLNumber, XSLOtherwise, XSLPreserveSpace, XSLScript, XSLSort, XSLStringConstructor, XSLStyleSheet, XSLTemplate, XSLText, XSLValueOf, XSLWhen

public abstract class StyleElement
extends ElementWithAttributes
implements Locator

Abstract superclass for all element nodes in the stylesheet.
Note: this class implements Locator. The element retains information about its own location in the stylesheet, which is useful when an XSL error is found.

Field Summary

static int
REPORT_ALWAYS
static int
REPORT_IF_INSTANTIATED
static int
REPORT_UNLESS_FORWARDS_COMPATIBLE
protected Vector
attributeSets
protected short[]
extensionNamespaces
protected int
reportingCircumstances
protected StaticContext
staticContext
protected TransformerConfigurationException
validationError
protected String
version

Fields inherited from class com.icl.saxon.tree.ElementWithAttributes

attributeList, namespaceList

Fields inherited from class com.icl.saxon.tree.ElementImpl

nameCode, root

Fields inherited from class com.icl.saxon.tree.ParentNodeImpl

sequence

Fields inherited from class com.icl.saxon.tree.NodeImpl

emptyArray, index, parent

Fields inherited from class com.icl.saxon.om.AbstractNode

NODE_LETTER

Fields inherited from interface com.icl.saxon.om.NodeInfo

ATTRIBUTE, COMMENT, ELEMENT, NAMESPACE, NODE, NONE, NUMBER_OF_TYPES, PI, ROOT, TEXT

Constructor Summary

StyleElement()
Constructor

Method Summary

Binding
bindVariable(int fingerprint)
Bind a variable used in this element to the XSLVariable element in which it is declared
void
checkEmpty()
Convenience method to check that the stylesheet element is empty
void
checkNotTopLevel()
Convenience method to check that the stylesheet element is not at the top level
void
checkTopLevel()
Convenience method to check that the stylesheet element is at the top level
protected void
checkUnknownAttribute(int nc)
Check whether an unknown attribute is permitted.
void
checkWithinTemplate()
Check that the stylesheet element is within a template body
protected void
compileError(String message)
protected void
compileError(TransformerException error)
Construct an exception with diagnostic information
protected boolean
definesExcludedNamespace(short uriCode)
Check whether this node excludes a particular namespace from the result.
protected boolean
definesExtensionElement(short uriCode)
Check whether a particular extension element namespace is defined on this node.
boolean
doesPostProcessing()
Determine whether this element does any processing after instantiating any children.
protected void
fallbackProcessing(StyleElement instruction, Context context)
Perform fallback processing
protected void
findAttributeSets(String use)
Determine the list of attribute-sets associated with this element.
boolean
forwardsCompatibleModeIsEnabled()
Determine whether forwards-compatible mode is enabled for this element
XSLStyleSheet
getContainingStyleSheet()
Get the containing XSLStyleSheet element
int
getPrecedence()
Get the import precedence of this stylesheet element.
PreparedStyleSheet
getPreparedStyleSheet()
Get the PreparedStyleSheet object.
protected XSLStyleSheet
getPrincipalStyleSheet()
Get the principal XSLStyleSheet node.
StandardNames
getStandardNames()
Get the StandardNames object
Function
getStyleSheetFunction(int fingerprint)
Get a Function declared using a saxon:function element in the stylesheet
Binding
getVariableBinding(int fprint)
Bind a variable used in this element to the XSLVariable element in which it is declared
Enumeration[]
getVariableNames()
List the variables that are in scope for this stylesheet element.
String
getVersion()
Get the version number on this element, or inherited from its ancestors
protected Expression
handleSortKeys(Expression select)
Modify the "select" expression to include any sort keys specified.
boolean
isExcludedNamespace(short uriCode)
Check whether a namespace uri defines an namespace excluded from the result.
boolean
isExtensionNamespace(short uriCode)
Check whether a namespace uri defines an extension element.
boolean
isInstruction()
Determine whether this node is an instruction.
boolean
isTopLevel()
Test whether this is a top-level element
Expression
makeAttributeValueTemplate(String expression)
Make an attribute value template in the context of this stylesheet element
Expression
makeExpression(String expression)
Make an expression in the context of this stylesheet element
Pattern
makePattern(String pattern)
Make a pattern in the context of this stylesheet element
boolean
mayContainTemplateBody()
Determine whether this type of element is allowed to contain a template-body
abstract void
prepareAttributes()
Set the attribute list for the element.
void
preprocess()
Default preprocessing method does nothing.
abstract void
process(Context context)
Process: called to do the real work of this stylesheet element.
void
processAllAttributes()
Process the attributes of this element and all its children
protected void
processAttributeSets(Context context)
Expand the attribute sets referenced in this element's use-attribute-sets attribute
void
processAttributes()
Process the attribute list for the element.
void
processChildren(Context context)
Process the children of this node in the stylesheet
protected void
processExcludedNamespaces(int nc)
Process the [xsl:]exclude-result-prefixes attribute if there is one
protected void
processExtensionElementAttribute(int nc)
Process the [xsl:]extension-element-prefixes attribute if there is one
protected void
processVersionAttribute(int nc)
Process the [xsl:]version attribute if there is one
void
reportAbsence(String attribute)
Convenience method to report the absence of a mandatory attribute
protected void
setValidationError(TransformerException reason, int circumstances)
Set a validation error
protected TransformerException
styleError(String message)
protected TransformerException
styleError(TransformerException error)
Construct an exception with diagnostic information
void
substituteFor(StyleElement temp)
Make this node a substitute for a temporary one previously added to the tree.
void
validate()
Check that the element is valid.
protected void
validateChildren()
void
validateSubtree()
Recursive walk through the stylesheet to validate all nodes

Methods inherited from class com.icl.saxon.tree.ElementWithAttributes

addNamespaceNodes, copy, getAttribute, getAttributeList, getAttributeNS, getAttributeNode, getAttributeNodeNS, getAttributeValue, getAttributeValue, getAttributeValue, getAttributes, getLength, getNamedItem, getNamedItemNS, getNamespaceCodes, getPrefixForURI, getURICodeForPrefix, hasAttribute, hasAttributeNS, hasAttributes, initialise, item, outputNamespaceNodes, removeAttribute, removeAttributeNS, removeAttributeNode, removeNamedItem, removeNamedItemNS, setAttribute, setAttributeNS, setAttributeNode, setAttributeNodeNS, setNamedItem, setNamedItemNS, setNamespaceDeclarations

Methods inherited from class com.icl.saxon.tree.ElementImpl

addNamespaceNodes, copy, copy, generateId, getAttributeList, getAttributeValue, getBaseURI, getDocumentRoot, getLineNumber, getNameCode, getNodeType, getPrefixForURI, getSystemId, getURICodeForPrefix, initialise, makeNameCode, outputNamespaceNodes, setAttribute, setLineNumber, setNameCode, setSystemId

Methods inherited from class com.icl.saxon.tree.ParentNodeImpl

addChild, compact, copyStringValue, dropChildren, enumerateChildren, getChildNodes, getFirstChild, getLastChild, getNodeValue, getNthChild, getSequenceNumber, getStringValue, hasChildNodes, removeChild, renumberChildren, useChildrenArray

Methods inherited from class com.icl.saxon.tree.NodeImpl

compareOrder, generateId, getAttributeValue, getAttributeValue, getAttributes, getBaseURI, getChildNodes, getDisplayName, getDocumentElement, getDocumentRoot, getEnumeration, getFingerprint, getFirstChild, getLastChild, getLineNumber, getLocalName, getNameCode, getNamePool, getNextInDocument, getNextSibling, getOriginatingNode, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getSequenceNumber, getSystemId, getURI, hasAttributes, hasChildNodes, isSameNodeInfo, outputNamespaceNodes, removeNode, setSystemId

Methods inherited from class com.icl.saxon.om.AbstractNode

appendChild, appendData, cloneNode, compareDocumentPosition, compareOrder, copyStringValue, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, generateId, getAttribute, getAttributeNS, getAttributeNode, getAttributeNodeNS, getAttributeValue, getAttributeValue, getAttributes, getBaseURI, getChildNodes, getColumnNumber, getData, getDisplayName, getDoctype, getDocumentElement, getDocumentRoot, getElementById, getElementsByTagName, getElementsByTagNameNS, getEnumeration, getFeature, getFingerprint, getFirstChild, getImplementation, getLastChild, getLength, getLineNumber, getLocalName, getName, getNameCode, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOriginatingNode, getOwnerDocument, getOwnerElement, getParent, getParentNode, getPrefix, getPreviousSibling, getPublicId, getSchemaTypeInfo, getSpecified, getSystemId, getTagName, getTextContent, getURI, getUserData, getValue, getWholeText, hasAttribute, hasAttributeNS, hasAttributes, hasChildNodes, importNode, insertBefore, insertData, isDefaultNamespace, isElementContentWhitespace, isEqualNode, isId, isSameNode, isSameNodeInfo, isSupported, lookupNamespaceURI, lookupPrefix, normalize, outputNamespaceNodes, removeAttribute, removeAttributeNS, removeAttributeNode, removeChild, replaceChild, replaceData, replaceWholeText, setAttributeNS, setAttributeNode, setAttributeNodeNS, setData, setIdAttribute, setIdAttributeNS, setIdAttributeNode, setNodeValue, setPrefix, setTextContent, setUserData, setValue, splitText, substringData, supports

Field Details

REPORT_ALWAYS

public static final int REPORT_ALWAYS
Field Value:
1

REPORT_IF_INSTANTIATED

public static final int REPORT_IF_INSTANTIATED
Field Value:
3

REPORT_UNLESS_FORWARDS_COMPATIBLE

public static final int REPORT_UNLESS_FORWARDS_COMPATIBLE
Field Value:
2

attributeSets

protected Vector attributeSets

extensionNamespaces

protected short[] extensionNamespaces

reportingCircumstances

protected int reportingCircumstances

staticContext

protected StaticContext staticContext

validationError

protected TransformerConfigurationException validationError

version

protected String version

Constructor Details

StyleElement

public StyleElement()
Constructor

Method Details

bindVariable

public Binding bindVariable(int fingerprint)
            throws XPathException
Bind a variable used in this element to the XSLVariable element in which it is declared
Parameters:
fingerprint - The fingerprint of the name of the variable
Returns:
a Binding for the variable
Throws:
XPathException - if the variable has not been declared

checkEmpty

public void checkEmpty()
            throws TransformerConfigurationException
Convenience method to check that the stylesheet element is empty

checkNotTopLevel

public void checkNotTopLevel()
            throws TransformerConfigurationException
Convenience method to check that the stylesheet element is not at the top level

checkTopLevel

public void checkTopLevel()
            throws TransformerConfigurationException
Convenience method to check that the stylesheet element is at the top level

checkUnknownAttribute

protected void checkUnknownAttribute(int nc)
            throws TransformerConfigurationException
Check whether an unknown attribute is permitted.
Parameters:
nc - The name code of the attribute name

checkWithinTemplate

public void checkWithinTemplate()
            throws TransformerConfigurationException
Check that the stylesheet element is within a template body

compileError

protected void compileError(String message)
            throws TransformerConfigurationException

compileError

protected void compileError(TransformerException error)
            throws TransformerConfigurationException
Construct an exception with diagnostic information

definesExcludedNamespace

protected boolean definesExcludedNamespace(short uriCode)
Check whether this node excludes a particular namespace from the result. This method checks this node only, not the ancestor nodes.
Parameters:
uriCode - the code of the namespace URI being tested

definesExtensionElement

protected boolean definesExtensionElement(short uriCode)
Check whether a particular extension element namespace is defined on this node. This checks this node only, not the ancestor nodes. The implementation checks whether the prefix is included in the [xsl:]extension-element-prefixes attribute.
Parameters:
uriCode - the namespace URI code being tested

doesPostProcessing

public boolean doesPostProcessing()
Determine whether this element does any processing after instantiating any children. The default implementation says it does. Tail recursion only works if call-template is nested entirely in elements that do no such processing. (If the element is empty, this property is irrelevant, because the element cannot contain an xsl:call-template).

fallbackProcessing

protected void fallbackProcessing(StyleElement instruction,
                                  Context context)
            throws TransformerException
Perform fallback processing

findAttributeSets

protected void findAttributeSets(String use)
            throws TransformerConfigurationException
Determine the list of attribute-sets associated with this element. This is used for xsl:element, xsl:copy, xsl:attribute-set, and on literal result elements

forwardsCompatibleModeIsEnabled

public boolean forwardsCompatibleModeIsEnabled()
Determine whether forwards-compatible mode is enabled for this element

getContainingStyleSheet

public XSLStyleSheet getContainingStyleSheet()
Get the containing XSLStyleSheet element

getPrecedence

public int getPrecedence()
Get the import precedence of this stylesheet element.

getPreparedStyleSheet

public PreparedStyleSheet getPreparedStyleSheet()
Get the PreparedStyleSheet object.
Returns:
the PreparedStyleSheet to which this stylesheet element belongs

getPrincipalStyleSheet

protected XSLStyleSheet getPrincipalStyleSheet()
Get the principal XSLStyleSheet node. This gets the principal style sheet, i.e. the one originally loaded, that forms the root of the import/include tree

getStandardNames

public final StandardNames getStandardNames()
Get the StandardNames object

getStyleSheetFunction

public Function getStyleSheetFunction(int fingerprint)
Get a Function declared using a saxon:function element in the stylesheet
Parameters:
fingerprint - the fingerprint of the name of the function
Returns:
the Function object represented by this saxon:function; or null if not found

getVariableBinding

public Binding getVariableBinding(int fprint)
Bind a variable used in this element to the XSLVariable element in which it is declared
Parameters:
fprint - The absolute name of the variable (as a namepool fingerprint)
Returns:
a Binding for the variable, or null if it has not been declared

getVariableNames

public Enumeration[] getVariableNames()
List the variables that are in scope for this stylesheet element. Designed for a debugger, not used by the processor.
Returns:
two Enumeration of Strings, the global ones [0] and the local ones [1]

getVersion

public String getVersion()
Get the version number on this element, or inherited from its ancestors

handleSortKeys

protected Expression handleSortKeys(Expression select)
            throws TransformerConfigurationException
Modify the "select" expression to include any sort keys specified. Used in XSLForEach and XSLApplyTemplates

isExcludedNamespace

public boolean isExcludedNamespace(short uriCode)
Check whether a namespace uri defines an namespace excluded from the result. This checks whether the namespace is defined as an excluded namespace on this or any ancestor node.
Parameters:
uriCode - the code of the namespace URI being tested

isExtensionNamespace

public boolean isExtensionNamespace(short uriCode)
Check whether a namespace uri defines an extension element. This checks whether the namespace is defined as an extension namespace on this or any ancestor node.
Parameters:
uriCode - the namespace URI code being tested

isInstruction

public boolean isInstruction()
Determine whether this node is an instruction. The default implementation says it isn't.

isTopLevel

public boolean isTopLevel()
Test whether this is a top-level element

makeAttributeValueTemplate

public Expression makeAttributeValueTemplate(String expression)
            throws TransformerConfigurationException
Make an attribute value template in the context of this stylesheet element

makeExpression

public Expression makeExpression(String expression)
            throws TransformerConfigurationException
Make an expression in the context of this stylesheet element

makePattern

public Pattern makePattern(String pattern)
            throws TransformerConfigurationException
Make a pattern in the context of this stylesheet element

mayContainTemplateBody

public boolean mayContainTemplateBody()
Determine whether this type of element is allowed to contain a template-body

prepareAttributes

public abstract void prepareAttributes()
            throws TransformerConfigurationException
Set the attribute list for the element. This is called to process the attributes (note the distinction from processAttributes in the superclass). Must be supplied in a subclass

preprocess

public void preprocess()
            throws TransformerConfigurationException
Default preprocessing method does nothing. It is implemented for those top-level elements that can be evaluated before the source document is available, for example xsl:key, xsl:attribute-set, xsl:template, xsl:locale

process

public abstract void process(Context context)
            throws TransformerException
Process: called to do the real work of this stylesheet element. This method must be implemented in each subclass.
Parameters:
context - The context in the source XML document, giving access to the current node, the current variables, etc.

processAllAttributes

public void processAllAttributes()
            throws TransformerConfigurationException
Process the attributes of this element and all its children

processAttributeSets

protected void processAttributeSets(Context context)
            throws TransformerException
Expand the attribute sets referenced in this element's use-attribute-sets attribute

processAttributes

public final void processAttributes()
            throws TransformerConfigurationException
Process the attribute list for the element. This is a wrapper method that calls prepareAttributes (provided in the subclass) and traps any exceptions

processChildren

public void processChildren(Context context)
            throws TransformerException
Process the children of this node in the stylesheet
Parameters:
context - The context in the source XML document, giving access to the current node, the current variables, etc.

processExcludedNamespaces

protected void processExcludedNamespaces(int nc)
            throws TransformerConfigurationException
Process the [xsl:]exclude-result-prefixes attribute if there is one
Parameters:
nc - the name code of the attribute required

processExtensionElementAttribute

protected void processExtensionElementAttribute(int nc)
            throws TransformerConfigurationException
Process the [xsl:]extension-element-prefixes attribute if there is one
Parameters:
nc - the name code of the attribute required

processVersionAttribute

protected void processVersionAttribute(int nc)
Process the [xsl:]version attribute if there is one
Parameters:
nc - the name code of the attribute required

reportAbsence

public void reportAbsence(String attribute)
            throws TransformerConfigurationException
Convenience method to report the absence of a mandatory attribute

setValidationError

protected void setValidationError(TransformerException reason,
                                  int circumstances)
Set a validation error

styleError

protected TransformerException styleError(String message)

styleError

protected TransformerException styleError(TransformerException error)
Construct an exception with diagnostic information

substituteFor

public void substituteFor(StyleElement temp)
Make this node a substitute for a temporary one previously added to the tree. See StyleNodeFactory for details. "A node like the other one in all things but its class". Note that at this stage, the node will not yet be known to its parent, though it will contain a reference to its parent; and it will have no children.

validate

public void validate()
            throws TransformerConfigurationException
Check that the element is valid. This is called once for each element, after the entire tree has been built. As well as validation, it can perform first-time initialisation. The default implementation does nothing; it is normally overriden in subclasses.

validateChildren

protected void validateChildren()
            throws TransformerConfigurationException

validateSubtree

public void validateSubtree()
            throws TransformerConfigurationException
Recursive walk through the stylesheet to validate all nodes