com.icl.saxon.tree
Class ElementImpl

java.lang.Object
  |
  +--com.icl.saxon.tree.NodeImpl
        |
        +--com.icl.saxon.tree.ParentNodeImpl
              |
              +--com.icl.saxon.tree.ElementImpl
All Implemented Interfaces:
org.w3c.dom.Element, ElementInfo, org.w3c.dom.NamedNodeMap, org.w3c.dom.Node, NodeInfo
Direct Known Subclasses:
ElementWithAttributes

public class ElementImpl
extends com.icl.saxon.tree.ParentNodeImpl
implements ElementInfo, org.w3c.dom.Element, org.w3c.dom.NamedNodeMap

ElementImpl implements an element with no attributes or namespace declarations.

This class is an implementation of ElementInfo. For elements with attributes or namespace declarations, class ElementWithAttributes is used.


Field Summary
protected static NodeInfo[] emptyArray
           
protected static SingletonEnumeration emptyEnumeration
           
protected  int index
           
protected  int nameCode
           
protected  com.icl.saxon.tree.ParentNodeImpl parent
           
protected  DocumentImpl root
           
protected  int sequence
           
 
Fields inherited from interface com.icl.saxon.om.NodeInfo
ATTRIBUTE, COMMENT, ELEMENT, NAMESPACE, NODE, NODE_TYPE_NAMES, NONE, NUMBER_OF_TYPES, PI, ROOT, 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
ElementImpl()
          Construct an empty ElementImpl
 
Method Summary
 void addChild(com.icl.saxon.tree.NodeImpl node, int index)
          Add a child node to this node.
 void addNamespaceNodes(ElementInfo owner, java.util.Vector list, boolean addXML)
          Make the set of all namespace nodes associated with this element.
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 org.w3c.dom.Node cloneNode(boolean deep)
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 void compact(int size)
          Compact the space used by this node
 void copy(Outputter out)
          Copy this node to a given outputter (supporting xsl:copy-of)
 void copy(Outputter out, boolean allNamespaces)
          Copy this node to a given outputter (supporting xsl:copy-of)
 void copyStringValue(Outputter out)
          Copy the string-value of this node to a given outputter
 void defaultAction(Context c)
          Perform default action for this kind of node (built-in template rule)
protected  void disallowUpdate()
          Internal method used to indicate that update operations are not allowed
 void dropChildren()
          Drop a branch of the tree.
 NodeEnumeration enumerateChildren()
          Get an enumeration of the children of this node
 NodeInfo[] getAllChildNodes()
          Get all child nodes of the element (child elements and character nodes).
 java.lang.String getAttribute(java.lang.String name)
          Retrieves an attribute value by name.
 ExtendedAttributes getAttributeList()
          Get the attribute list for this element.
 org.w3c.dom.Attr getAttributeNode(java.lang.String name)
          Retrieves an attribute node by name.
 org.w3c.dom.Attr getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
          Retrieves an Attr node by local name and namespace URI.
 java.lang.String getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Retrieves an attribute value by local name and namespace URI.
 org.w3c.dom.NamedNodeMap getAttributes()
          A NamedNodeMap containing the attributes of this element.
 java.lang.String getAttributeValue(int fingerprint)
          Get the value of a given attribute of this node
 java.lang.String getAttributeValue(Name name)
          Find the value of a given attribute of this element.
 java.lang.String getAttributeValue(java.lang.String name)
          Find the value of a given attribute of this element.
 java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)
          Find the value of a given attribute of this node.
 org.w3c.dom.NodeList getChildNodes()
          Return a NodeList that contains all children of this node.
 java.lang.String getDisplayName()
          Get the display name of this node.
 org.w3c.dom.Element getDocumentElement()
          Get the outermost element.
 DocumentInfo getDocumentRoot()
          Get the root node
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
          Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
 org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.
 int getFingerprint()
          Get the fingerprint of the node.
 org.w3c.dom.Node getFirstChild()
          Get the first child node of the element
 int getIndex()
          Get the index of this node, i.e.
 org.w3c.dom.Node getLastChild()
          Get the last child node of the element
 int getLength()
          Get number of attributes (DOM NamedNodeMap method).
 int getLineNumber()
          Get the line number of the node within its source document entity
 java.lang.String getLocalName()
          Get the local name of this node.
 int getNameCode()
          Get the nameCode of the node.
 org.w3c.dom.Node getNamedItem(java.lang.String name)
          Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.
 org.w3c.dom.Node getNamedItemNS(java.lang.String uri, java.lang.String localName)
          Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.
 NamePool getNamePool()
          Get the NamePool
 java.lang.String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 NodeInfo getNextInDocument(NodeInfo anchor)
          Get the next node in document order
 org.w3c.dom.Node getNextSibling()
          Get next sibling node
 java.lang.String getNodeName()
          Get the name of this node, following the DOM rules
 short getNodeType()
          Return the type of node.
 java.lang.String getNodeValue()
          The value of this node (as defined in DOM).
protected  NodeInfo getNthChild(int n)
          Get the nth child node of the element (numbering from 0)
 int getNumberOfChildren()
          Get the number of children.
 org.w3c.dom.Document getOwnerDocument()
          Return the Document object associated with this node.
 org.w3c.dom.Node getParentNode()
          Find the parent node of this node.
 java.lang.String getPath()
          Generate a path to this node
 java.lang.String getPrefix()
          Get the prefix part of the name of this node.
 java.lang.String getPrefixForURI(java.lang.String uri)
          Search the NamespaceList for a given URI, returning the corresponding prefix.
 NodeInfo getPreviousInDocument()
          Get the previous node in document order
 org.w3c.dom.Node getPreviousSibling()
          Get the previous sibling of the node
 java.lang.String getPublicId()
          Get the public identifier of the document entity containing this node.
 long getSequenceNumber()
          Get the node sequence number (in document order).
 java.lang.String getSequentialKey()
          Get a character string that uniquely identifies this node and that collates nodes into document order
 java.lang.String getSystemId()
          Get the base URI for the node.
 java.lang.String getTagName()
          The name of the element (DOM interface).
 java.lang.String getURI()
          Get the URI part of the name of this node.
 short getURICode()
          Get URI code.
 short getURICodeForPrefix(java.lang.String prefix)
          Search the NamespaceList for a given prefix, returning the corresponding URI.
 java.lang.String getValue()
          Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
 boolean hasAttribute(java.lang.String name)
          Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.
 boolean hasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          Determine whether the node has any children.
 void initialise(int nameCode, AttributeCollection atts, NodeInfo parent, java.lang.String baseURI, int lineNumber, int sequenceNumber)
          Initialise a new ElementImpl with an element name
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Insert the node newChild before the existing child node refChild.
 boolean isa(int nodeType)
          Determine whether the node is of a given type.
 boolean isDocumentElement()
          Determine whether this node is the outermost element.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
 boolean isSupported(java.lang.String feature, java.lang.String version)
          Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
 org.w3c.dom.Node item(int index)
          Get n'th attribute (DOM NamedNodeMap method).
 AttributeInfo makeAttributeNode(int index)
          Make an attribute node for a given attribute of this element
 AttributeInfo makeAttributeNodeFS(int fingerprint)
          Make an attribute node for a given attribute fingerprint of this element
 int makeNameCode(java.lang.String qname, boolean useDefault)
          Make a NameCode, using this Element as the context for namespace resolution.
 void normalize()
          Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
 void outputNamespaceNodes(Outputter out, boolean includeAncestors)
          Output all namespace nodes associated with this element.
 void removeAttribute(java.lang.String name)
          Removes an attribute by name.
 org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
          Removes the specified attribute node.
 void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Removes an attribute by local name and namespace URI.
 void removeChild(int index)
          Remove node at given index.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Remove the child node indicated by oldChild from the list of children, and returns it.
 org.w3c.dom.Node removeNamedItem(java.lang.String name)
          Remove named attribute (DOM NamedNodeMap method: always fails)
 org.w3c.dom.Node removeNamedItemNS(java.lang.String uri, java.lang.String localName)
          Remove named attribute (DOM NamedNodeMap method: always fails)
 void removeNode()
          Remove this node from the tree.
 void renumberChildren()
          Renumber the children of a given parent node.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replace the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setAttribute(java.lang.String name, java.lang.String value)
          Set the value of an attribute on the current element.
 org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
          Adds a new attribute node.
 org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
          Add a new attribute.
 void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)
          Adds a new attribute.
 void setLineNumber(int line)
          Set the line number of the element within its source document entity
 void setNameCode(int nameCode)
          Set the name code.
 org.w3c.dom.Node setNamedItem(org.w3c.dom.Node arg)
          Set named attribute (DOM NamedNodeMap method: always fails)
 org.w3c.dom.Node setNamedItemNS(org.w3c.dom.Node arg)
          Set named attribute (DOM NamedNodeMap method: always fails)
 void setNodeValue(java.lang.String nodeValue)
          Set the node value.
 void setPrefix(java.lang.String prefix)
          Set the namespace prefix of this node.
 java.lang.String toString()
          Create a string that identifies the node (for diagnostic purposes only)
 void useChildrenArray(com.icl.saxon.tree.NodeImpl[] array)
          Supply an array to be used for the array of children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.icl.saxon.om.NodeInfo
copyStringValue, defaultAction, enumerateChildren, getAllChildNodes, getAttributeValue, getAttributeValue, getDisplayName, getDocumentElement, getFingerprint, getIndex, getLocalName, getNextInDocument, getNodeName, getNumberOfChildren, getPrefix, getPreviousInDocument, getSequenceNumber, getSequentialKey, getURI, getURICode, getValue, isDocumentElement, isSameNode
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getNamespaceURI, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

nameCode

protected int nameCode

root

protected DocumentImpl root

sequence

protected int sequence

emptyArray

protected static NodeInfo[] emptyArray

emptyEnumeration

protected static SingletonEnumeration emptyEnumeration

parent

protected com.icl.saxon.tree.ParentNodeImpl parent

index

protected int index
Constructor Detail

ElementImpl

public ElementImpl()
Construct an empty ElementImpl
Method Detail

setNameCode

public void setNameCode(int nameCode)
Set the name code. Used when creating a dummy element in the Stripper

initialise

public void initialise(int nameCode,
                       AttributeCollection atts,
                       NodeInfo parent,
                       java.lang.String baseURI,
                       int lineNumber,
                       int sequenceNumber)
                throws org.xml.sax.SAXException
Initialise a new ElementImpl with an element name
Parameters:
name - The element name, with namespaces resolved
atts - The attribute list: always null
parent - The parent node

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root node
Specified by:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in class com.icl.saxon.tree.NodeImpl
Following copied from interface: com.icl.saxon.om.NodeInfo
Returns:
the DocumentInfo representing the containing document

getSystemId

public final java.lang.String getSystemId()
Get the base URI for the node.
Specified by:
getSystemId in interface NodeInfo
Overrides:
getSystemId in class com.icl.saxon.tree.NodeImpl
Following copied from interface: com.icl.saxon.om.NodeInfo
Returns:
the System Identifier of the entity in the source document containing the node, or null if not known

setLineNumber

public void setLineNumber(int line)
Set the line number of the element within its source document entity

getLineNumber

public int getLineNumber()
Get the line number of the node within its source document entity
Specified by:
getLineNumber in interface NodeInfo
Overrides:
getLineNumber in class com.icl.saxon.tree.NodeImpl
Following copied from interface: com.icl.saxon.om.NodeInfo
Returns:
the line number of the node in its original source document; or -1 if not available

getNameCode

public int getNameCode()
Get the nameCode of the node. This is used to locate the name in the NamePool
Specified by:
getNameCode in interface NodeInfo
Overrides:
getNameCode in class com.icl.saxon.tree.NodeImpl

getURICodeForPrefix

public short getURICodeForPrefix(java.lang.String prefix)
                          throws org.xml.sax.SAXException
Search the NamespaceList for a given prefix, returning the corresponding URI.
Specified by:
getURICodeForPrefix in interface ElementInfo
Parameters:
prefix - The prefix to be matched. To find the default namespace, supply ""
Returns:
The URI code corresponding to this namespace. If it is an unnamed default namespace, return Namespace.NULL_CODE.
Throws:
org.xml.sax.SAXException - if the prefix has not been declared on this NamespaceList.

getPrefixForURI

public java.lang.String getPrefixForURI(java.lang.String uri)
Search the NamespaceList for a given URI, returning the corresponding prefix.
Specified by:
getPrefixForURI in interface ElementInfo
Parameters:
uri - The URI to be matched.
Returns:
The prefix corresponding to this URI. If not found, return null. If there is more than one prefix matching the URI, the first one found is returned. If the URI matches the default namespace, return an empty string.

makeNameCode

public final int makeNameCode(java.lang.String qname,
                              boolean useDefault)
                       throws org.xml.sax.SAXException
Make a NameCode, using this Element as the context for namespace resolution. The name will be entered in the namepool: therefore this method should not be called once the name pool is sealed.
Parameters:
qname - The name as written, in the form "[prefix:]localname"

addNamespaceNodes

public void addNamespaceNodes(ElementInfo owner,
                              java.util.Vector list,
                              boolean addXML)
                       throws org.xml.sax.SAXException
Make the set of all namespace nodes associated with this element.
Specified by:
addNamespaceNodes in interface ElementInfo
Parameters:
owner - The element owning these namespace nodes.
list - a Vector containing NamespaceInfo objects representing the namespaces in scope for this element; the method appends nodes to this Vector, which should initially be empty. Note that the returned list will never contain the XML namespace (to get this, the NamespaceEnumeration class adds it itself). The list WILL include an entry for the undeclaration xmlns=""; again it is the job of NamespaceEnumeration to ignore this, since it doesn't represent a true namespace node.
addXML - Add the XML namespace node to the list

outputNamespaceNodes

public void outputNamespaceNodes(Outputter out,
                                 boolean includeAncestors)
                          throws org.xml.sax.SAXException
Output all namespace nodes associated with this element.
Specified by:
outputNamespaceNodes in interface ElementInfo
Parameters:
out - The relevant outputter

getNodeType

public final short getNodeType()
Return the type of node.
Specified by:
getNodeType in interface NodeInfo
Returns:
NodeInfo.ELEMENT

getAttributeList

public ExtendedAttributes getAttributeList()
Get the attribute list for this element.
Specified by:
getAttributeList in interface ElementInfo
Returns:
The attribute list. This will not include any namespace attributes. The attribute names will be in expanded form, with prefixes replaced by URIs

getAttributeValue

public java.lang.String getAttributeValue(Name name)
Find the value of a given attribute of this element.
This is a short-cut method; the full capability to examine attributes is offered via the getAttributeList() method.
The attribute may either be one that was present in the original XML document, or one that has been set by the application using setAttribute().
Parameters:
name - the name of an attribute. Any prefix in the name is interpreted in the context of the namespaces applying to the current element
Returns:
the value of the attribute, if it exists, otherwise null

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String name)
Find the value of a given attribute of this element.
This is a short-cut method; the full capability to examine attributes is offered via the getAttributeList() method.
The attribute may either be one that was present in the original XML document, or one that has been set by the application using setAttribute().
Specified by:
getAttributeValue in interface NodeInfo
Overrides:
getAttributeValue in class com.icl.saxon.tree.NodeImpl
Parameters:
name - the name of an attribute. There must be no prefix in the name.
Returns:
the value of the attribute, if it exists, otherwise null

makeAttributeNode

public AttributeInfo makeAttributeNode(int index)
Make an attribute node for a given attribute of this element
Specified by:
makeAttributeNode in interface ElementInfo
Parameters:
uri - The attribute name's uri
localName - The local name of the attribute

makeAttributeNodeFS

public AttributeInfo makeAttributeNodeFS(int fingerprint)
Make an attribute node for a given attribute fingerprint of this element
Specified by:
makeAttributeNodeFS in interface ElementInfo
Parameters:
fingerprint - The attribute name's fingerprint

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
                  throws org.w3c.dom.DOMException
Set the value of an attribute on the current element.
Specified by:
setAttribute in interface org.w3c.dom.Element
Throws:
org.w3c.dom.DOMException - (always): the Saxon tree is immutable

copy

public void copy(Outputter out)
          throws org.xml.sax.SAXException
Copy this node to a given outputter (supporting xsl:copy-of)
Specified by:
copy in interface NodeInfo

copy

public void copy(Outputter out,
                 boolean allNamespaces)
          throws org.xml.sax.SAXException
Copy this node to a given outputter (supporting xsl:copy-of)
Parameters:
out - The outputter
allNamespaces - true if namespaces for ancestor nodes must be output

getPath

public java.lang.String getPath()
Generate a path to this node
Specified by:
getPath in interface NodeInfo

getTagName

public java.lang.String getTagName()
The name of the element (DOM interface).
Specified by:
getTagName in interface org.w3c.dom.Element

getNodeValue

public java.lang.String getNodeValue()
The value of this node (as defined in DOM). Always null.
Specified by:
getNodeValue in interface org.w3c.dom.Node
Overrides:
getNodeValue in class com.icl.saxon.tree.ParentNodeImpl

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Retrieves an attribute value by name. This is a DOM method, so namespace declarations count as attributes.
Specified by:
getAttribute in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
A NamedNodeMap containing the attributes of this element. This is a DOM method, so the list of attributes includes namespace declarations.
Specified by:
getAttributes in interface org.w3c.dom.Node
Overrides:
getAttributes in class com.icl.saxon.tree.NodeImpl

removeAttribute

public void removeAttribute(java.lang.String name)
Removes an attribute by name.
Specified by:
removeAttribute in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to remove.

getAttributeNode

public org.w3c.dom.Attr getAttributeNode(java.lang.String name)
Retrieves an attribute node by name. This is a DOM method, so namespace declarations are treated as attributes.
To retrieve an attribute node by qualified name and namespace URI, use the getAttributeNodeNS method.
Specified by:
getAttributeNode in interface org.w3c.dom.Element
Parameters:
name - The name (nodeName ) of the attribute to retrieve.
Returns:
The Attr node with the specified name ( nodeName ) or null if there is no such attribute.

setAttributeNode

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
                                  throws org.w3c.dom.DOMException
Adds a new attribute node. Always fails
Specified by:
setAttributeNode in interface org.w3c.dom.Element
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

removeAttributeNode

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
                                     throws org.w3c.dom.DOMException
Removes the specified attribute node. Always fails
Specified by:
removeAttributeNode in interface org.w3c.dom.Element
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
Specified by:
getElementsByTagName in interface org.w3c.dom.Element
Parameters:
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching Element nodes.

getAttributeNS

public java.lang.String getAttributeNS(java.lang.String namespaceURI,
                                       java.lang.String localName)
Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.
Specified by:
getAttributeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.
Since:
DOM Level 2

setAttributeNS

public void setAttributeNS(java.lang.String namespaceURI,
                           java.lang.String qualifiedName,
                           java.lang.String value)
                    throws org.w3c.dom.DOMException
Adds a new attribute. Always fails.
Specified by:
setAttributeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to create or alter.
qualifiedName - The qualified name of the attribute to create or alter.
value - The value to set in string form.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

removeAttributeNS

public void removeAttributeNS(java.lang.String namespaceURI,
                              java.lang.String localName)
                       throws org.w3c.dom.DOMException
Removes an attribute by local name and namespace URI. Always fails
Specified by:
removeAttributeNS in interface org.w3c.dom.Element
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
Since:
DOM Level 2

getAttributeNodeNS

public org.w3c.dom.Attr getAttributeNodeNS(java.lang.String namespaceURI,
                                           java.lang.String localName)
Retrieves an Attr node by local name and namespace URI. DOM method, so namespace declarations count as attributes.
Specified by:
getAttributeNodeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The Attr node with the specified attribute local name and namespace URI or null if there is no such attribute.
Since:
DOM Level 2

setAttributeNodeNS

public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
                                    throws org.w3c.dom.DOMException
Add a new attribute. Always fails.
Specified by:
setAttributeNodeNS in interface org.w3c.dom.Element
Parameters:
newAttr - The Attr node to add to the attribute list.
Returns:
If the newAttr attribute replaces an existing attribute with the same local name and namespace URI , the replaced Attr node is returned, otherwise null is returned.
Throws:
org.w3c.dom.DOMException -
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
Since:
DOM Level 2

getElementsByTagNameNS

public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                                   java.lang.String localName)
Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.
Specified by:
getElementsByTagNameNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements .
Since:
DOM Level 2

hasAttribute

public boolean hasAttribute(java.lang.String name)
Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise. This is a DOM method, so namespace declarations are treated as attributes.
Specified by:
hasAttribute in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to look for.
Returns:
true if an attribute with the given name is specified on this element or has a default value, false otherwise.
Since:
DOM Level 2

hasAttributeNS

public boolean hasAttributeNS(java.lang.String namespaceURI,
                              java.lang.String localName)
Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise. This is a DOM method so namespace declarations are treated as attributes.
Specified by:
hasAttributeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to look for.
localName - The local name of the attribute to look for.
Returns:
true if an attribute with the given local name and namespace URI is specified or has a default value on this element, false otherwise.
Since:
DOM Level 2

getNamedItem

public org.w3c.dom.Node getNamedItem(java.lang.String name)
Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.
Specified by:
getNamedItem in interface org.w3c.dom.NamedNodeMap

setNamedItem

public org.w3c.dom.Node setNamedItem(org.w3c.dom.Node arg)
                              throws org.w3c.dom.DOMException
Set named attribute (DOM NamedNodeMap method: always fails)
Specified by:
setNamedItem in interface org.w3c.dom.NamedNodeMap

removeNamedItem

public org.w3c.dom.Node removeNamedItem(java.lang.String name)
                                 throws org.w3c.dom.DOMException
Remove named attribute (DOM NamedNodeMap method: always fails)
Specified by:
removeNamedItem in interface org.w3c.dom.NamedNodeMap

item

public org.w3c.dom.Node item(int index)
Get n'th attribute (DOM NamedNodeMap method). Namespace declarations are treated as attributes.
Specified by:
item in interface org.w3c.dom.NamedNodeMap

getLength

public int getLength()
Get number of attributes (DOM NamedNodeMap method). Treats namespace declarations as attributes.
Specified by:
getLength in interface org.w3c.dom.NamedNodeMap

getNamedItemNS

public org.w3c.dom.Node getNamedItemNS(java.lang.String uri,
                                       java.lang.String localName)
Get named attribute (DOM NamedNodeMap method) Treats namespace declarations as attributes.
Specified by:
getNamedItemNS in interface org.w3c.dom.NamedNodeMap

setNamedItemNS

public org.w3c.dom.Node setNamedItemNS(org.w3c.dom.Node arg)
                                throws org.w3c.dom.DOMException
Set named attribute (DOM NamedNodeMap method: always fails)
Specified by:
setNamedItemNS in interface org.w3c.dom.NamedNodeMap

removeNamedItemNS

public org.w3c.dom.Node removeNamedItemNS(java.lang.String uri,
                                          java.lang.String localName)
                                   throws org.w3c.dom.DOMException
Remove named attribute (DOM NamedNodeMap method: always fails)
Specified by:
removeNamedItemNS in interface org.w3c.dom.NamedNodeMap

getSequenceNumber

public long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and roots) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position.
Overrides:
getSequenceNumber in class com.icl.saxon.tree.NodeImpl

getNumberOfChildren

public int getNumberOfChildren()
Get the number of children.
Overrides:
getNumberOfChildren in class com.icl.saxon.tree.NodeImpl

getAllChildNodes

public NodeInfo[] getAllChildNodes()
Get all child nodes of the element (child elements and character nodes).
Overrides:
getAllChildNodes in class com.icl.saxon.tree.NodeImpl
Returns:
a vector containing a NodeInfo for each child node

enumerateChildren

public NodeEnumeration enumerateChildren()
Get an enumeration of the children of this node
Overrides:
enumerateChildren in class com.icl.saxon.tree.NodeImpl

getFirstChild

public org.w3c.dom.Node getFirstChild()
Get the first child node of the element
Overrides:
getFirstChild in class com.icl.saxon.tree.NodeImpl
Returns:
the first child node of the required type, or null if there are no children

getLastChild

public org.w3c.dom.Node getLastChild()
Get the last child node of the element
Overrides:
getLastChild in class com.icl.saxon.tree.NodeImpl
Returns:
the last child of the element, or null if there are no children

getNthChild

protected final NodeInfo getNthChild(int n)
Get the nth child node of the element (numbering from 0)
Returns:
the last child of the element, or null if there is no n'th child

getValue

public java.lang.String getValue()
Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
Returns:
the accumulated character content of the element, including descendant elements.

copyStringValue

public void copyStringValue(Outputter out)
                     throws org.xml.sax.SAXException
Copy the string-value of this node to a given outputter
Overrides:
copyStringValue in class com.icl.saxon.tree.NodeImpl

defaultAction

public void defaultAction(Context c)
                   throws org.xml.sax.SAXException
Perform default action for this kind of node (built-in template rule)

useChildrenArray

public void useChildrenArray(com.icl.saxon.tree.NodeImpl[] array)
Supply an array to be used for the array of children. For system use only.

addChild

public void addChild(com.icl.saxon.tree.NodeImpl node,
                     int index)
Add a child node to this node. For system use only. Note: normalizing adjacent text nodes is the responsibility of the caller.

removeChild

public void removeChild(int index)
Remove node at given index. Will always be followed by a renumberChildren().

renumberChildren

public void renumberChildren()
Renumber the children of a given parent node. For system use only

dropChildren

public void dropChildren()
Drop a branch of the tree. The target element remains in the tree, but its children are disconnected from the parent. Unless there are other references to the children (e.g. in a variable) they will be deleted from memory next time the garbage collector comes round.

compact

public void compact(int size)
Compact the space used by this node

isSameNode

public boolean isSameNode(NodeInfo other)
Determine whether this is the same node as another node
Specified by:
isSameNode in interface NodeInfo
Returns:
true if this Node object and the supplied Node object represent the same node in the tree.

getFingerprint

public int getFingerprint()
Get the fingerprint of the node. This is used to compare whether two nodes have equivalent names.
Specified by:
getFingerprint in interface NodeInfo

getNamePool

public NamePool getNamePool()
Get the NamePool

getPrefix

public java.lang.String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.
Specified by:
getPrefix in interface NodeInfo
Returns:
the prefix part of the name. For an unnamed node, return an empty string.

getURI

public java.lang.String getURI()
Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.
Specified by:
getURI in interface NodeInfo
Returns:
The URI of the namespace of this node. For the default namespace, return an empty string. For an unnamed node, return null.

getURICode

public short getURICode()
Get URI code. This is a number that uniquely identifies the namespace URI of the node, within its NamePool
Specified by:
getURICode in interface NodeInfo

getNodeName

public java.lang.String getNodeName()
Get the name of this node, following the DOM rules
Specified by:
getNodeName in interface NodeInfo
Returns:
The name of the node. For an element this is the element name, for an attribute it is the attribute name, as a QName. Other node types return conventional names such as "#text" or "#comment"

getDisplayName

public java.lang.String getDisplayName()
Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.
Specified by:
getDisplayName in interface NodeInfo
Returns:
The display name of this node. For a node with no name, return an empty string.

getLocalName

public java.lang.String getLocalName()
Get the local name of this node.
Specified by:
getLocalName in interface NodeInfo
Returns:
The local name of this node. For a node with no name, return an empty string.

getPublicId

public java.lang.String getPublicId()
Get the public identifier of the document entity containing this node. This is not currently maintained: return null

getIndex

public final int getIndex()
Get the index of this node, i.e. its position among its siblings
Specified by:
getIndex in interface NodeInfo
Following copied from interface: com.icl.saxon.om.NodeInfo
Returns:
the number of preceding sibling nodes at the same level

getParentNode

public final org.w3c.dom.Node getParentNode()
Find the parent node of this node.
Specified by:
getParentNode in interface org.w3c.dom.Node
Returns:
The Node object describing the containing element or root node.

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Get the previous sibling of the node
Specified by:
getPreviousSibling in interface org.w3c.dom.Node
Returns:
The previous sibling node. Returns null if the current node is the first child of its parent.

getNextSibling

public org.w3c.dom.Node getNextSibling()
Get next sibling node
Specified by:
getNextSibling in interface org.w3c.dom.Node
Returns:
The next sibling node of the required type. Returns null if the current node is the last child of its parent.

isa

public final boolean isa(int nodeType)
Determine whether the node is of a given type.

Note, this can also be done by testing the node using "instanceof". But this is inconvenient when passing the class as a parameter to another routine.

Parameters:
nodeType - One of the specific node types such as ELEMENT or TEXT, or the general node type NODE
Returns:
true if the node is an instance of the specified node type

hasAttributes

public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes.
Specified by:
hasAttributes in interface org.w3c.dom.Node
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String uri,
                                          java.lang.String localName)
Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.
Specified by:
getAttributeValue in interface NodeInfo
Parameters:
uri - the namespace uri of an attribute
localName - the local name of an attribute
Returns:
the value of the attribute, if it exists, otherwise null

getAttributeValue

public java.lang.String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node
Specified by:
getAttributeValue in interface NodeInfo
Parameters:
fingerprint - The fingerprint of the attribute name
Returns:
the attribute value if it exists or null if not

isDocumentElement

public boolean isDocumentElement()
Determine whether this node is the outermost element.
Specified by:
isDocumentElement in interface NodeInfo
Returns:
True if this element is the document (outermost) element.

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
Get the outermost element.
Specified by:
getDocumentElement in interface NodeInfo
Returns:
the ElementInfo for the outermost element of the document. If the document is not well-formed, this returns the last element child of the root if there is one, otherwise null.

getNextInDocument

public NodeInfo getNextInDocument(NodeInfo anchor)
Get the next node in document order
Specified by:
getNextInDocument in interface NodeInfo
Parameters:
anchor: - the scan stops when it reaches a node that is not a descendant of the specified anchor node
Returns:
the next node in the document, or null if there is no such node

getPreviousInDocument

public NodeInfo getPreviousInDocument()
Get the previous node in document order
Specified by:
getPreviousInDocument in interface NodeInfo
Returns:
the previous node in the document, or null if there is no such node

getSequentialKey

public java.lang.String getSequentialKey()
Get a character string that uniquely identifies this node and that collates nodes into document order
Specified by:
getSequentialKey in interface NodeInfo
Returns:
a string.

toString

public java.lang.String toString()
Create a string that identifies the node (for diagnostic purposes only)
Overrides:
toString in class java.lang.Object

removeNode

public void removeNode()
                throws org.xml.sax.SAXException
Remove this node from the tree. For system use only. When one or more nodes have been removed, renumberChildren() must be called to adjust the numbering of remaining nodes. PRECONDITION: The node must have a parent node.

setNodeValue

public void setNodeValue(java.lang.String nodeValue)
                  throws org.w3c.dom.DOMException
Set the node value. DOM method: always fails
Specified by:
setNodeValue in interface org.w3c.dom.Node

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Return a NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.
Specified by:
getChildNodes in interface org.w3c.dom.Node

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
Return the Document object associated with this node. (DOM mehod)
Specified by:
getOwnerDocument in interface org.w3c.dom.Node

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
Insert the node newChild before the existing child node refChild. DOM method: always fails.
Specified by:
insertBefore in interface org.w3c.dom.Node
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
                              throws org.w3c.dom.DOMException
Replace the child node oldChild with newChild in the list of children, and returns the oldChild node. Always fails.
Specified by:
replaceChild in interface org.w3c.dom.Node
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
Remove the child node indicated by oldChild from the list of children, and returns it. DOM method: always fails.
Specified by:
removeChild in interface org.w3c.dom.Node
Parameters:
oldChild - The node being removed.
Returns:
The node removed.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
Adds the node newChild to the end of the list of children of this node. DOM method: always fails.
Specified by:
appendChild in interface org.w3c.dom.Node
Parameters:
newChild - The node to add.
Returns:
The node added.
Throws:
org.w3c.dom.DOMException -
NO_MODIFICATION_ALLOWED_ERR: Always raised.

hasChildNodes

public boolean hasChildNodes()
Determine whether the node has any children.
Specified by:
hasChildNodes in interface org.w3c.dom.Node
Returns:
true if the node has any children, false if the node has no children.

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent. Not implemented: always returns null. (Because trees are read-only, there would be no way of using the resulting node.)
Specified by:
cloneNode in interface org.w3c.dom.Node
Parameters:
deep - If true , recursively clone the subtree under the specified node; if false , clone only the node itself (and its attributes, if it is an Element ).
Returns:
The duplicate node.

normalize

public void normalize()
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
Specified by:
normalize in interface org.w3c.dom.Node
Since:
DOM Level 2

isSupported

public boolean isSupported(java.lang.String feature,
                           java.lang.String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
Specified by:
isSupported in interface org.w3c.dom.Node
Parameters:
feature - The name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation .
version - This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true .
Returns:
Returns true if the specified feature is supported on this node, false otherwise.
Since:
DOM Level 2

getNamespaceURI

public java.lang.String getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null . Per the Namespaces in XML Specification an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.
Specified by:
getNamespaceURI in interface org.w3c.dom.Node
Since:
DOM Level 2

setPrefix

public void setPrefix(java.lang.String prefix)
               throws org.w3c.dom.DOMException
Set the namespace prefix of this node. Always fails.
Specified by:
setPrefix in interface org.w3c.dom.Node

disallowUpdate

protected void disallowUpdate()
                       throws org.w3c.dom.DOMException
Internal method used to indicate that update operations are not allowed