com.icl.saxon.style
Class StyleElement

java.lang.Object
  |
  +--com.icl.saxon.tree.NodeImpl
        |
        +--com.icl.saxon.tree.ParentNodeImpl
              |
              +--com.icl.saxon.tree.ElementImpl
                    |
                    +--com.icl.saxon.tree.ElementWithAttributes
                          |
                          +--com.icl.saxon.style.StyleElement
All Implemented Interfaces:
org.w3c.dom.Element, ElementInfo, org.xml.sax.Locator, org.w3c.dom.NamedNodeMap, org.w3c.dom.Node, NodeInfo, StaticContext
Direct Known Subclasses:
AbsentExtensionElement, LiteralResultElement, SAXONDoctype, SAXONEntityRef, SAXONFunction, SAXONItem, SAXONOutput, SAXONPreview, SAXONWhile, SQLConnect, SQLInsert, XSLApplyImports, XSLApplyTemplates, XSLAttribute, XSLAttributeSet, XSLCallTemplate, XSLChoose, XSLComment, XSLCopy, XSLCopyOf, XSLDecimalFormat, XSLElement, XSLFallback, XSLForEach, XSLGeneralIncorporate, XSLGeneralVariable, XSLIf, XSLKey, XSLMessage, XSLNamespaceAlias, XSLNumber, XSLOtherwise, XSLOutput, XSLPreserveSpace, XSLProcessingInstruction, XSLSort, XSLStyleSheet, XSLTemplate, XSLText, XSLValueOf, XSLWhen

public abstract class StyleElement
extends ElementWithAttributes
implements org.xml.sax.Locator, StaticContext

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
protected  java.util.Vector attributeSets
           
protected  java.lang.String version
           
 
Fields inherited from class com.icl.saxon.tree.ElementWithAttributes
attributeList, namespaceList
 
Fields inherited from class com.icl.saxon.tree.ElementImpl
emptyArray, fullName, index, parent, sequence
 
Fields inherited from interface com.icl.saxon.om.NodeInfo
ATTRIBUTE, COMMENT, DOCUMENT, ELEMENT, NAMESPACE, NODE, NONE, NUMBER_OF_TYPES, PI, TEXT
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
StyleElement()
          Constructor creates an empty attribute list
 
Method Summary
 void allowAttributes(java.lang.String[] allowed)
          Test that all attributes are included in the permitted list of attributes for the element.
 Binding bindVariable(java.lang.String name)
          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
 void checkWithinTemplate()
          Check that the stylesheet element is within a template body
protected  boolean definesExcludedNamespace(java.lang.String namespace)
          Check whether this node excludes a particular namespace from the result.
protected  boolean definesExtensionElement(java.lang.String namespace)
          Check whether a particular extension element namespace is defined on this node.
 java.lang.String expandChildren(Context context)
          Expand the stylesheet elements subordinate to this one, returning the result as a string.
protected  void findAttributeSets(java.lang.String use)
          Determine the list of attribute-sets associated with this element.
 boolean forwardsCompatibleModeIsEnabled()
          Determine whether forwards-compatible mode is enabled for this element
 int getPrecedence()
          Get the import precedence of this stylesheet element.
protected  PreparedStyleSheet getPreparedStyleSheet()
          Get the PreparedStyleSheet object.
protected  XSLStyleSheet getPrincipalStyleSheet()
          Get the containing XSLStyleSheet node.
 Function getStyleSheetFunction(Name name)
          Get a Function declared using a saxon:function element in the stylesheet
 Binding getVariableBinding(java.lang.String name)
          Bind a variable used in this element to the XSLVariable element in which it is declared
 java.util.Enumeration[] getVariableNames()
          List the variables that are in scope for this stylesheet element.
 java.lang.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(java.lang.String uri)
          Check whether a namespace uri defines an namespace excluded from the result.
 boolean isExtensionNamespace(java.lang.String uri)
          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
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
 void processAttributes()
          Process the attribute list for the element.
protected  void processAttributeSets(Context context)
          Expand the attribute sets referenced in this element's use-attribute-sets attribute
 void processChildren(Context context)
          Process the children of this node in the stylesheet
protected  void processExcludedNamespaces()
          Process the [xsl:]exclude-result-prefixes attribute if there is one
protected  void processExtensionElementAttribute()
          Process the [xsl:]extension-element-prefixes attribute if there is one
protected  void processVersionAttribute()
          Process the [xsl:]version attribute if there is one
 void reportAbsence(java.lang.String attribute)
          Convenience method to report the absence of a mandatory attribute
 boolean requiresXSLprefix()
          Determine whether "xsl:" prefix is required on standard attributes: true for literal result elements, false otherwise
protected  org.xml.sax.SAXException styleError(org.xml.sax.SAXException error)
          Construct an exception with diagnostic information
protected  org.xml.sax.SAXException styleError(java.lang.String message)
           
 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.
 void validateSubtree()
          Recursive walk through the stylesheet to validate all nodes
 
Methods inherited from class com.icl.saxon.tree.ElementWithAttributes
addNamespaceNodes, copy, getAttribute, getAttributeList, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getAttributeValue, getAttributeValue, getLength, getNamedItem, getNamedItemNS, getPrefixForURI, getURIforPrefix, hasAttribute, hasAttributeNS, hasAttributes, initialise, item, makeAttributeNode, outputNamespaceNodes, removeAttribute, removeAttributeNode, removeAttributeNS, removeNamedItem, removeNamedItemNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setNamedItem, setNamedItemNS, setNamespaceDeclarations
 
Methods inherited from class com.icl.saxon.tree.ElementImpl
addChild, alphaKey, appendChild, cloneNode, compact, copyStringValue, defaultAction, disallowUpdate, dropChildren, getAbsoluteName, getAllChildNodes, getAncestor, getAncestor, getChildNodes, getColumnNumber, getDisplayName, getDocumentElement, getDocumentRoot, getElementsByTagName, getElementsByTagNameNS, getExpandedName, getFirstChild, getFirstChild, getIndex, getInheritedAttribute, getLastChild, getLastChild, getLineNumber, getLocalName, getNamespaceURI, getNextInDocument, getNextSibling, getNextSibling, getNodeName, getNodeType, getNodeTypeName, getNodeValue, getNthChild, getNumberAny, getNumberMulti, getNumberOfChildren, getNumberSimple, getNumberSimple, getNumberSingle, getOwnerDocument, getParentNode, getPath, getPrefix, getPreviousInDocument, getPreviousInDocument, getPreviousSibling, getPreviousSibling, getPublicId, getSequenceNumber, getSequentialKey, getSystemId, getTagName, getURI, getValue, hasChildNodes, hasName, insertBefore, isa, isAncestor, isDocumentElement, isFirstChild, isFirstInGroup, isLastChild, isLastInGroup, isSameNode, isSupported, makeName, makePrefixTest, normalize, removeChild, removeChild, removeNode, renumberChildren, replaceChild, setLineNumber, setNodeValue, setPrefix, supports, toString, useChildrenArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xml.sax.Locator
getColumnNumber, getLineNumber, getPublicId, getSystemId
 
Methods inherited from interface com.icl.saxon.expr.StaticContext
getLineNumber, getSystemId, makeName, makePrefixTest
 
Methods inherited from interface com.icl.saxon.om.ElementInfo
getInheritedAttribute, isFirstChild, isFirstInGroup, isLastChild, isLastInGroup
 
Methods inherited from interface com.icl.saxon.om.NodeInfo
copyStringValue, defaultAction, getAbsoluteName, getAllChildNodes, getAncestor, getAncestor, getDisplayName, getDocumentElement, getDocumentRoot, getExpandedName, getFirstChild, getIndex, getLastChild, getLineNumber, getLocalName, getNextInDocument, getNextSibling, getNodeName, getNodeType, getNumberAny, getNumberMulti, getNumberOfChildren, getNumberSimple, getNumberSimple, getNumberSingle, getPath, getPrefix, getPreviousInDocument, getPreviousInDocument, getPreviousSibling, getSequenceNumber, getSequentialKey, getSystemId, getURI, getValue, hasName, isa, isAncestor, isDocumentElement, isSameNode
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 
Methods inherited from interface org.w3c.dom.Element
getElementsByTagName, getElementsByTagNameNS, getTagName
 

Field Detail

attributeSets

protected java.util.Vector attributeSets

version

protected java.lang.String version
Constructor Detail

StyleElement

public StyleElement()
Constructor creates an empty attribute list
Method Detail

substituteFor

public void substituteFor(StyleElement temp)
                   throws org.xml.sax.SAXException
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.

isInstruction

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

getPrecedence

public int getPrecedence()
                  throws org.xml.sax.SAXException
Get the import precedence of this stylesheet element.

processAllAttributes

public void processAllAttributes()
                          throws org.xml.sax.SAXException
Process the attributes of this element and all its children

processAttributes

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

allowAttributes

public void allowAttributes(java.lang.String[] allowed)
                     throws org.xml.sax.SAXException
Test that all attributes are included in the permitted list of attributes for the element. More precisely, that each attribute is either in the permitted list of attributes or is in a non-default namespace.
Parameters:
allowed - An array of strings indicating the permitted attribute names
Throws:
org.xml.sax.SAXException - if an attribute is present that isn't in the approved list.

prepareAttributes

public abstract void prepareAttributes()
                                throws org.xml.sax.SAXException
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

requiresXSLprefix

public boolean requiresXSLprefix()
Determine whether "xsl:" prefix is required on standard attributes: true for literal result elements, false otherwise

processExtensionElementAttribute

protected void processExtensionElementAttribute()
                                         throws org.xml.sax.SAXException
Process the [xsl:]extension-element-prefixes attribute if there is one

processExcludedNamespaces

protected void processExcludedNamespaces()
                                  throws org.xml.sax.SAXException
Process the [xsl:]exclude-result-prefixes attribute if there is one

processVersionAttribute

protected void processVersionAttribute()
                                throws org.xml.sax.SAXException
Process the [xsl:]version attribute if there is one

getVersion

public java.lang.String getVersion()
                            throws org.xml.sax.SAXException
Get the version number on this element, or inherited from its ancestors

forwardsCompatibleModeIsEnabled

public boolean forwardsCompatibleModeIsEnabled()
                                        throws org.xml.sax.SAXException
Determine whether forwards-compatible mode is enabled for this element
Specified by:
forwardsCompatibleModeIsEnabled in interface StaticContext

definesExtensionElement

protected boolean definesExtensionElement(java.lang.String namespace)
                                   throws org.xml.sax.SAXException
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:
namespace - the namespace URI being tested

isExtensionNamespace

public boolean isExtensionNamespace(java.lang.String uri)
                             throws org.xml.sax.SAXException
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.
Specified by:
isExtensionNamespace in interface StaticContext
Parameters:
uri - the namespace URI being tested

definesExcludedNamespace

protected boolean definesExcludedNamespace(java.lang.String namespace)
                                    throws org.xml.sax.SAXException
Check whether this node excludes a particular namespace from the result. This method checks this node only, not the ancestor nodes.
Parameters:
namespace - the namespace URI being tested

isExcludedNamespace

public boolean isExcludedNamespace(java.lang.String uri)
                            throws org.xml.sax.SAXException
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:
uri - the namespace URI being tested

validate

public void validate()
              throws org.xml.sax.SAXException
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.

preprocess

public void preprocess()
                throws org.xml.sax.SAXException
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

validateSubtree

public void validateSubtree()
                     throws org.xml.sax.SAXException
Recursive walk through the stylesheet to validate all nodes

getPrincipalStyleSheet

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

getPreparedStyleSheet

protected PreparedStyleSheet getPreparedStyleSheet()
                                            throws org.xml.sax.SAXException
Get the PreparedStyleSheet object.
Returns:
the PreparedStyleSheet to which this stylesheet element belongs

checkWithinTemplate

public void checkWithinTemplate()
                         throws org.xml.sax.SAXException
Check that the stylesheet element is within a template body
Throws:
org.xml.sax.SAXException - if not within a template body

checkTopLevel

public void checkTopLevel()
                   throws org.xml.sax.SAXException
Convenience method to check that the stylesheet element is at the top level
Throws:
org.xml.sax.SAXException - if not at top level

checkNotTopLevel

public void checkNotTopLevel()
                      throws org.xml.sax.SAXException
Convenience method to check that the stylesheet element is not at the top level
Throws:
org.xml.sax.SAXException - if it is at the top level

checkEmpty

public void checkEmpty()
                throws org.xml.sax.SAXException
Convenience method to check that the stylesheet element is empty
Throws:
org.xml.sax.SAXException - if it is not empty

reportAbsence

public void reportAbsence(java.lang.String attribute)
                   throws org.xml.sax.SAXException
Convenience method to report the absence of a mandatory attribute
Throws:
org.xml.sax.SAXException - if the attribute is missing

process

public abstract void process(Context context)
                      throws org.xml.sax.SAXException
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.

processChildren

public void processChildren(Context context)
                     throws org.xml.sax.SAXException
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.

handleSortKeys

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

expandChildren

public java.lang.String expandChildren(Context context)
                                throws org.xml.sax.SAXException
Expand the stylesheet elements subordinate to this one, returning the result as a string. The expansion must not generate any element or attribute nodes.
Parameters:
context - The context in the source document

findAttributeSets

protected void findAttributeSets(java.lang.String use)
                          throws org.xml.sax.SAXException
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

processAttributeSets

protected void processAttributeSets(Context context)
                             throws org.xml.sax.SAXException
Expand the attribute sets referenced in this element's use-attribute-sets attribute

styleError

protected org.xml.sax.SAXException styleError(org.xml.sax.SAXException error)
Construct an exception with diagnostic information

styleError

protected org.xml.sax.SAXException styleError(java.lang.String message)

isTopLevel

public boolean isTopLevel()
                   throws org.xml.sax.SAXException
Test whether this is a top-level element

bindVariable

public Binding bindVariable(java.lang.String name)
                     throws org.xml.sax.SAXException
Bind a variable used in this element to the XSLVariable element in which it is declared
Specified by:
bindVariable in interface StaticContext
Returns:
a Binding for the variable

getVariableBinding

public Binding getVariableBinding(java.lang.String name)
                           throws org.xml.sax.SAXException
Bind a variable used in this element to the XSLVariable element in which it is declared
Returns:
a Binding for the variable, or null if it has not been declared

getVariableNames

public java.util.Enumeration[] getVariableNames()
                                         throws org.xml.sax.SAXException
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]

getStyleSheetFunction

public Function getStyleSheetFunction(Name name)
                               throws org.xml.sax.SAXException
Get a Function declared using a saxon:function element in the stylesheet
Specified by:
getStyleSheetFunction in interface StaticContext
Parameters:
name - the name of the function
Returns:
the Function object represented by this saxon:function; or null if not found