com.icl.saxon.om

Class AbstractNode

Implemented Interfaces:
DOMLocator, Node, NodeInfo, Source, SourceLocator
Known Direct Subclasses:
NodeImpl, TinyNodeImpl

public abstract class AbstractNode
extends java.lang.Object
implements Node, NodeInfo, SourceLocator, DOMLocator

This class is an abstract implementation of the Saxon NodeInfo interface; it also contains concrete implementations of most of the DOM methods in terms of the NodeInfo methods. These include all the methods defined on the DOM Node class itself, and most of those defined on subclasses such as Document, Text, and Comment: because of the absence of multiple inheritance, this is the only way of making these methods reusable by multiple implementations. The class contains no data, and can be used as a common superclass for different implementations of Node and NodeInfo.
Author:
Michael H. Kay

Field Summary

static char[]
NODE_LETTER
Chararacteristic letters to identify each type of node, indexed using the node type values.

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

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

Method Summary

Node
appendChild(Node newChild)
Adds the node newChild to the end of the list of children of this node.
void
appendData(String arg)
Append the string to the end of the character data of the node.
Node
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
short
compareDocumentPosition(Node other)
Compares the reference node, i.e.
abstract int
compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order.
void
copyStringValue(Outputter out)
Copy the string-value of this node to a given outputter.
Attr
createAttribute(String name)
Create an Attr of the given name.
Attr
createAttributeNS(String namespaceURI, String qualifiedName)
Create an attribute of the given qualified name and namespace URI.
CDATASection
createCDATASection(String data)
Create a CDATASection node whose value is the specified string.
Comment
createComment(String data)
Create a Comment node given the specified string.
DocumentFragment
createDocumentFragment()
Creates an empty DocumentFragment object.
Element
createElement(String tagName)
Creates an element of the type specified.
Element
createElementNS(String namespaceURI, String qualifiedName)
Create an element of the given qualified name and namespace URI.
EntityReference
createEntityReference(String name)
Create an EntityReference object.
ProcessingInstruction
createProcessingInstruction(String target, String data)
Create a ProcessingInstruction node given the specified name and data strings.
Text
createTextNode(String data)
Create a Text node given the specified string.
void
deleteData(int offset, int count)
Remove a range of 16-bit units from the node.
protected void
disallowUpdate()
Internal method used to indicate that update operations are not allowed
abstract String
generateId()
Get a character string that uniquely identifies this node
String
getAttribute(String name)
Retrieves an attribute value by name.
String
getAttributeNS(String namespaceURI, String localName)
Retrieves an attribute value by local name and namespace URI.
Attr
getAttributeNode(String name)
Retrieves an attribute node by name.
Attr
getAttributeNodeNS(String namespaceURI, String localName)
Retrieves an Attr node by local name and namespace URI.
abstract String
getAttributeValue(String uri, String localName)
Find the value of a given attribute of this node.
abstract String
getAttributeValue(int fingerprint)
Get the value of a given attribute of this node
NamedNodeMap
getAttributes()
Return a NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise.
abstract String
getBaseURI()
Get the base URI for the node.
NodeList
getChildNodes()
Return a NodeList that contains all children of this node.
int
getColumnNumber()
Get the column number of the node.
String
getData()
Get the character data of a Text or Comment node.
String
getDisplayName()
Get the display name of this node.
DocumentType
getDoctype()
Get the Document Type Declaration (see DocumentType ) associated with this document.
Element
getDocumentElement()
Get the outermost element.
DocumentInfo
getDocumentRoot()
Get the root (document) node
Element
getElementById(String elementId)
Return the Element whose ID is given by elementId .
NodeList
getElementsByTagName(String tagname)
Return a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
NodeList
getElementsByTagNameNS(String namespaceURI, String localName)
Return a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.
abstract AxisEnumeration
getEnumeration(byte axisNumber, NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node
Object
getFeature(String feature, String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in .
abstract int
getFingerprint()
Get the fingerprint of the node, used for matching names
Node
getFirstChild()
Get first child (DOM method)
DOMImplementation
getImplementation()
Get a DOMImplementation object that handles this document.
Node
getLastChild()
Get last child (DOM method)
int
getLength()
Get the length of a Text or Comment node.
int
getLineNumber()
Get the line number of the node within its source document entity.
abstract String
getLocalName()
Get the local name of this node.
String
getName()
Get the name of an attribute node (the QName) (DOM method)
abstract int
getNameCode()
Get the name code of the node, used for displaying names
String
getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.
Node
getNextSibling()
Get next sibling node (DOM method)
String
getNodeName()
Get the name of this node, following the DOM rules
String
getNodeValue()
Get the node value as defined in the DOM.
Node
getOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator
Document
getOwnerDocument()
Return the Document object associated with this node.
Element
getOwnerElement()
The Element node this attribute is attached to or null if this attribute is not in use.
abstract NodeInfo
getParent()
Find the parent node of this node.
Node
getParentNode()
Find the parent node of this node (DOM method).
abstract String
getPrefix()
Get the prefix part of the name of this node.
Node
getPreviousSibling()
Get the previous sibling of the node (DOM method)
String
getPublicId()
Get the public identifier of the document entity containing this node.
org.w3c.dom.TypeInfo
getSchemaTypeInfo()
The type information associated with this attribute.
boolean
getSpecified()
If this attribute was explicitly given a value in the original document, this is true ; otherwise, it is false.
abstract String
getSystemId()
Get the system ID for the entity containing the node.
String
getTagName()
The name of the element (DOM interface).
String
getTextContent()
This attribute returns the text content of this node and its descendants.
abstract String
getURI()
Get the URI part of the name of this node.
Object
getUserData(String key)
Retrieves the object associated to a key on a this node.
String
getValue()
Return the character value of an attribute node (DOM method)
String
getWholeText()
Returns all text of Text nodes logically-adjacent text nodes to this node, concatenated in document order.
boolean
hasAttribute(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(String namespaceURI, 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.
abstract boolean
hasAttributes()
Returns whether this node has any attributes.
abstract boolean
hasChildNodes()
Determine whether the node has any children.
Node
importNode(Node importedNode, boolean deep)
Import a node from another document to this document.
Node
insertBefore(Node newChild, Node refChild)
Insert the node newChild before the existing child node refChild.
void
insertData(int offset, String arg)
Insert a string at the specified character offset.
boolean
isDefaultNamespace(String namespaceURI)
This method checks if the specified namespaceURI is the default namespace or not.
boolean
isElementContentWhitespace()
Returns whether this text node contains element content whitespace, often abusively called "ignorable whitespace".
boolean
isEqualNode(Node arg)
Tests whether two nodes are equal.
boolean
isId()
Returns whether this attribute is known to be of type ID (i.e.
boolean
isSameNode(Node other)
Returns whether this node is the same node as the given one.
abstract boolean
isSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node
boolean
isSupported(String feature, String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
String
lookupNamespaceURI(String prefix)
Look up the namespace URI associated to the given prefix, starting from this node.
String
lookupPrefix(String namespaceURI)
Look up the prefix associated to the given namespace URI, starting from this node.
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(String oldAttr)
Removes the specified attribute.
void
removeAttributeNS(String namespaceURI, String localName)
Removes an attribute by local name and namespace URI.
Attr
removeAttributeNode(Attr oldAttr)
Removes the specified attribute node.
Node
removeChild(Node oldChild)
Remove the child node indicated by oldChild from the list of children, and returns it.
Node
replaceChild(Node newChild, Node oldChild)
Replace the child node oldChild with newChild in the list of children, and returns the oldChild node.
void
replaceData(int offset, int count, String arg)
Replace the characters starting at the specified 16-bit unit offset with the specified string.
Text
replaceWholeText(String content)
Replaces the text of the current node and all logically-adjacent text nodes with the specified text.
void
setAttributeNS(String namespaceURI, String qualifiedName, String value)
Adds a new attribute.
Attr
setAttributeNode(Attr newAttr)
Adds a new attribute node.
Attr
setAttributeNodeNS(Attr newAttr)
Add a new attribute.
void
setData(String data)
Set the character data of a Text or Comment node.
void
setIdAttribute(String name, boolean isId)
If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute .
void
setIdAttributeNS(String namespaceURI, String localName, boolean isId)
If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute .
void
setIdAttributeNode(Attr idAttr, boolean isId)
If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute .
void
setNodeValue(String nodeValue)
Set the node value.
void
setPrefix(String prefix)
Set the namespace prefix of this node.
void
setTextContent(String textContent)
This attribute returns the text content of this node and its descendants.
Object
setUserData(String key, Object data, org.w3c.dom.UserDataHandler handler)
Associate an object to a key on this node.
void
setValue(String value)
Set the value of an attribute node.
Text
splitText(int offset)
Break this node into two nodes at the specified offset, keeping both in the tree as siblings.
String
substringData(int offset, int count)
Extract a range of data from a Text or Comment node.
boolean
supports(String feature, String version)
Alternative to isSupported(), defined in a draft DOM spec

Field Details

NODE_LETTER

public static final char[] NODE_LETTER
Chararacteristic letters to identify each type of node, indexed using the node type values. These are used as the initial letter of the result of generate-id()

Method Details

appendChild

public Node appendChild(Node newChild)
            throws DOMException
Adds the node newChild to the end of the list of children of this node. DOM method: always fails.
Parameters:
newChild - The node to add.
Returns:
The node added.

appendData

public void appendData(String arg)
            throws DOMException
Append the string to the end of the character data of the node. DOM method: always fails.
Parameters:
arg - The DOMString to append.

cloneNode

public 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.)
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.

compareDocumentPosition

public short compareDocumentPosition(Node other)
            throws DOMException
Compares the reference node, i.e. the node on which this method is being called, with a node, i.e. the one passed as a parameter, with regard to their position in the document and according to the document order.
Parameters:
other - The node to compare against the reference node.
Returns:
Returns how the node is positioned relatively to the reference node.
Since:
DOM Level 3

compareOrder

public abstract int compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order. The other node will always be in the same document.
Specified by:
compareOrder in interface NodeInfo
Parameters:
other - The other node, whose position is to be compared with this node
Returns:
-1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())

copyStringValue

public void copyStringValue(Outputter out)
            throws TransformerException
Copy the string-value of this node to a given outputter. Default implementation does "out.writeContent(getStringValue());" but it is useful to provide an optimized implementation.
Specified by:
copyStringValue in interface NodeInfo

createAttribute

public Attr createAttribute(String name)
            throws DOMException
Create an Attr of the given name. DOM method: always fails, because the Saxon tree is not updateable.
Parameters:
name - The name of the attribute.
Returns:
A new Attr object with the nodeName attribute set to name , and localName , prefix , and namespaceURI set to null .

createAttributeNS

public Attr createAttributeNS(String namespaceURI,
                              String qualifiedName)
            throws DOMException
Create an attribute of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method. DOM method: returns null, because the Saxon tree is not updateable.
Parameters:
namespaceURI - The namespace URI of the attribute to create.
qualifiedName - The qualified name of the attribute to instantiate.
Returns:
A new Attr object.

createCDATASection

public CDATASection createCDATASection(String data)
            throws DOMException
Create a CDATASection node whose value is the specified string. DOM method: always fails, because the Saxon tree is not updateable.
Parameters:
data - The data for the CDATASection contents.
Returns:
The new CDATASection object.

createComment

public Comment createComment(String data)
Create a Comment node given the specified string. DOM method: returns null, because the Saxon tree is not updateable.
Parameters:
data - The data for the node.
Returns:
The new Comment object.

createDocumentFragment

public DocumentFragment createDocumentFragment()
Creates an empty DocumentFragment object.
Returns:
A new DocumentFragment . DOM method: returns null, because the Saxon tree is not updateable.

createElement

public Element createElement(String tagName)
            throws DOMException
Creates an element of the type specified. DOM method: always fails, because the Saxon tree is not updateable.

createElementNS

public Element createElementNS(String namespaceURI,
                               String qualifiedName)
            throws DOMException
Create an element of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method. DOM method: always fails, because the Saxon tree is not updateable.
Parameters:
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
A new Element object

createEntityReference

public EntityReference createEntityReference(String name)
            throws DOMException
Create an EntityReference object. DOM method: returns null, because the Saxon tree is not updateable.
Parameters:
name - The name of the entity to reference.
Returns:
The new EntityReference object.

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target,
                                                         String data)
            throws DOMException
Create a ProcessingInstruction node given the specified name and data strings. DOM method: returns null, because the Saxon tree is not updateable.
Parameters:
target - The target part of the processing instruction.
data - The data for the node.
Returns:
The new ProcessingInstruction object.

createTextNode

public Text createTextNode(String data)
Create a Text node given the specified string. DOM method: returns null, because the Saxon tree is not updateable.
Parameters:
data - The data for the node.
Returns:
The new Text object.

deleteData

public void deleteData(int offset,
                       int count)
            throws DOMException
Remove a range of 16-bit units from the node. DOM method: always fails.
Parameters:
offset - The offset from which to start removing.
count - The number of 16-bit units to delete.

disallowUpdate

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

generateId

public abstract String generateId()
Get a character string that uniquely identifies this node
Specified by:
generateId in interface NodeInfo
Returns:
a string.

getAttribute

public String getAttribute(String name)
Retrieves an attribute value by name. Namespace declarations will not be retrieved. DOM interface.
Parameters:
name - The QName 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.

getAttributeNS

public String getAttributeNS(String namespaceURI,
                             String localName)
Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.
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

getAttributeNode

public Attr getAttributeNode(String name)
Retrieves an attribute node by name. Namespace declarations will not be retrieved.
To retrieve an attribute node by qualified name and namespace URI, use the getAttributeNodeNS method.
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.

getAttributeNodeNS

public Attr getAttributeNodeNS(String namespaceURI,
                               String localName)
Retrieves an Attr node by local name and namespace URI. DOM method, so namespace declarations count as attributes.
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

getAttributeValue

public abstract String getAttributeValue(String uri,
                                         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 abstract 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

getAttributes

public NamedNodeMap getAttributes()
Return a NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise. (DOM method)

getBaseURI

public abstract String getBaseURI()
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.
Specified by:
getBaseURI in interface NodeInfo

getChildNodes

public NodeList getChildNodes()
Return a NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. DOM Method.

getColumnNumber

public int getColumnNumber()
Get the column number of the node. The default implementation returns -1, meaning unknown

getData

public String getData()
Get the character data of a Text or Comment node. DOM method.

getDisplayName

public 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.

getDoctype

public DocumentType getDoctype()
Get the Document Type Declaration (see DocumentType ) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. DOM method.
Returns:
null: The Saxon tree model does not include the document type information.

getDocumentElement

public Element getDocumentElement()
Get the outermost element. (DOM method)
Returns:
the Element 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.

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root (document) node
Specified by:
getDocumentRoot in interface NodeInfo
Returns:
the DocumentInfo representing the containing document

getElementById

public Element getElementById(String elementId)
Return the Element whose ID is given by elementId . If no such element exists, returns null . Behavior is not defined if more than one element has this ID . The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null .
Parameters:
elementId - The unique id value for an element.
Returns:
The matching element, or null if there is none.
Since:
DOM Level 2

getElementsByTagName

public NodeList getElementsByTagName(String tagname)
Return a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
Parameters:
tagname - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A new NodeList object containing all the matched Elements .

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Return a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree. DOM method.
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

getEnumeration

public abstract AxisEnumeration getEnumeration(byte axisNumber,
                                               NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node
Specified by:
getEnumeration in interface NodeInfo
Parameters:
axisNumber - The axis to be used (a constant in class Axis)
nodeTest - A pattern to be matched by the returned nodes
Returns:
a AxisEnumeration that scans the nodes reached by the axis in turn.

getFeature

public Object getFeature(String feature,
                         String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in . This method also allow the implementation to provide specialized objects which do not support the Node interface.
Parameters:
feature - The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.
version - This is the version number of the feature to test.
Returns:
Returns an object which implements the specialized APIs of the specified feature and version, if any, or null if there is no object which implements interfaces associated with that feature. If the DOMObject returned by this method implements the Node interface, it must delegate to the primary core Node and not return results inconsistent with the primary core Node such as attributes, childNodes, etc.

The Saxon implementation of this method always returns null

Since:
DOM Level 3

getFingerprint

public abstract int getFingerprint()
Get the fingerprint of the node, used for matching names
Specified by:
getFingerprint in interface NodeInfo

getFirstChild

public Node getFirstChild()
Get first child (DOM method)
Returns:
the first child node of this node, or null if it has no children

getImplementation

public DOMImplementation getImplementation()
Get a DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations. DOM method.

getLastChild

public Node getLastChild()
Get last child (DOM method)
Returns:
last child of this node, or null if it has no children

getLength

public int getLength()
Get the length of a Text or Comment node. DOM method.

getLineNumber

public int getLineNumber()
Get the line number of the node within its source document entity. The default implementation returns -1, meaning unknown
Specified by:
getLineNumber in interface NodeInfo

getLocalName

public abstract 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.

getName

public String getName()
Get the name of an attribute node (the QName) (DOM method)

getNameCode

public abstract int getNameCode()
Get the name code of the node, used for displaying names
Specified by:
getNameCode in interface NodeInfo

getNamespaceURI

public String getNamespaceURI()
The namespace URI of this node, or null if it is unspecified. DOM method.
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.
Since:
DOM Level 2

getNextSibling

public Node getNextSibling()
Get next sibling node (DOM method)
Returns:
The next sibling node. Returns null if the current node is the last child of its parent.

getNodeName

public String getNodeName()
Get the name of this node, following the DOM rules
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"

getNodeValue

public String getNodeValue()
Get the node value as defined in the DOM. This is not necessarily the same as the XPath string-value.

getOriginatingNode

public Node getOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator

getOwnerDocument

public Document getOwnerDocument()
Return the Document object associated with this node. (DOM method)

getOwnerElement

public Element getOwnerElement()
The Element node this attribute is attached to or null if this attribute is not in use.
Since:
DOM Level 2

getParent

public abstract NodeInfo getParent()
Find the parent node of this node.
Specified by:
getParent in interface NodeInfo
Returns:
The Node object describing the containing element or root node.

getParentNode

public Node getParentNode()
Find the parent node of this node (DOM method).
Returns:
The Node object describing the containing element or root node.

getPrefix

public abstract 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 "".

getPreviousSibling

public Node getPreviousSibling()
Get the previous sibling of the node (DOM method)
Returns:
The previous sibling node. Returns null if the current node is the first child of its parent.

getPublicId

public String getPublicId()
Get the public identifier of the document entity containing this node. The default implementation returns null, meaning unknown

getSchemaTypeInfo

public org.w3c.dom.TypeInfo getSchemaTypeInfo()
The type information associated with this attribute. While the type information contained in this attribute is guarantee to be correct after loading the document or invoking Document.normalizeDocument(), schemaTypeInfo may not be reliable if the node was moved.

This implementation always returns null;

Since:
DOM Level 3

getSpecified

public boolean getSpecified()
If this attribute was explicitly given a value in the original document, this is true ; otherwise, it is false. (DOM method)
Returns:
Always true in this implementation.

getSystemId

public abstract String getSystemId()
Get the system ID for the entity containing the node.
Specified by:
getSystemId in interface NodeInfo

getTagName

public String getTagName()
The name of the element (DOM interface).

getTextContent

public String getTextContent()
            throws DOMException
This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced by a single Text node containing the string this attribute is set to.
On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attribute Text.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:
Node typeContent
ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODEconcatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODEnodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODEnull

The Saxon implementation returns the same result as getStringValue()

Since:
DOM Level 3

getURI

public abstract 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 an unnamed node, or for an element or attribute in the default namespace, return an empty string.

getUserData

public Object getUserData(String key)
Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.

The Saxon implementation always returns null.

Parameters:
key - The key the object is associated to.
Returns:
Returns the DOMUserData associated to the given key on this node, or null if there was none.
Since:
DOM Level 3

getValue

public String getValue()
Return the character value of an attribute node (DOM method)
Returns:
the attribute value

getWholeText

public String getWholeText()
Returns all text of Text nodes logically-adjacent text nodes to this node, concatenated in document order.
For instance, in the example below wholeText on the Text node that contains "bar" returns "barfoo", while on the Text node that contains "foo" it returns "barfoo".
Since:
DOM Level 3

hasAttribute

public boolean hasAttribute(String name)
Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise. Namespace declarations will not be retrieved.
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(String namespaceURI,
                              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. Namespace declarations will not be retrieved.
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

hasAttributes

public abstract boolean hasAttributes()
Returns whether this node has any attributes.
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2

hasChildNodes

public abstract boolean hasChildNodes()
Determine whether the node has any children.
Specified by:
hasChildNodes in interface NodeInfo
Returns:
true if this node has any attributes, false otherwise.

importNode

public Node importNode(Node importedNode,
                       boolean deep)
            throws DOMException
Import a node from another document to this document. DOM method: always fails, because the Saxon tree is not updateable.
Since:
DOM Level 2

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
            throws DOMException
Insert the node newChild before the existing child node refChild. DOM method: always fails.
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.

insertData

public void insertData(int offset,
                       String arg)
            throws DOMException
Insert a string at the specified character offset. DOM method: always fails.
Parameters:
offset - The character offset at which to insert.
arg - The DOMString to insert.

isDefaultNamespace

public boolean isDefaultNamespace(String namespaceURI)
This method checks if the specified namespaceURI is the default namespace or not.
Parameters:
namespaceURI - The namespace URI to look for.
Returns:
Returns true if the specified namespaceURI is the default namespace, false otherwise.
Since:
DOM Level 3

isElementContentWhitespace

public boolean isElementContentWhitespace()
Returns whether this text node contains element content whitespace, often abusively called "ignorable whitespace". The text node is determined to contain whitespace in element content during the load of the document or if validation occurs while using Document.normalizeDocument().

The Saxon implementation always returns false.

Since:
DOM Level 3

isEqualNode

public boolean isEqualNode(Node arg)
Tests whether two nodes are equal.
This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with Node.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied:
  • The two nodes are of the same type.
  • The following string attributes are equal: nodeName, localName, namespaceURI, prefix, nodeValue . This is: they are both null, or they have the same length and are character for character identical.
  • The attributes NamedNodeMaps are equal. This is: they are both null, or they have the same length and for each node that exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index.
  • The childNodes NodeLists are equal. This is: they are both null, or they have the same length and contain equal nodes at the same index. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.

For two DocumentType nodes to be equal, the following conditions must also be satisfied:
  • The following string attributes are equal: publicId, systemId, internalSubset.
  • The entities NamedNodeMaps are equal.
  • The notations NamedNodeMaps are equal.

On the other hand, the following do not affect equality: the ownerDocument, baseURI, and parentNode attributes, the specified attribute for Attr nodes, the schemaTypeInfo attribute for Attr and Element nodes, the Text.isElementContentWhitespace attribute for Text nodes, as well as any user data or event listeners registered on the nodes.

Note: As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking. Note that future versions of this specification may take into account more attributes and implementations conform to this specification are expected to be updated accordingly.

Parameters:
arg - The node to compare equality with.
Returns:
Returns true if the nodes are equal, false otherwise.
Since:
DOM Level 3

isId

public boolean isId()
Returns whether this attribute is known to be of type ID (i.e. to contain an identifier for its owner element) or not.

This implementation always returns false.

Since:
DOM Level 3

isSameNode

public boolean isSameNode(Node other)
Returns whether this node is the same node as the given one.
This method provides a way to determine whether two Node references returned by the implementation reference the same object. When two Node references are references to the same object, even if through a proxy, the references may be used completely interchangeably, such that all attributes have the same values and calling the same DOM method on either reference always has exactly the same effect.
Parameters:
other - The node to test against.
Returns:
Returns true if the nodes are the same, false otherwise.
Since:
DOM Level 3

isSameNodeInfo

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

isSupported

public boolean isSupported(String feature,
                           String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this 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

lookupNamespaceURI

public String lookupNamespaceURI(String prefix)
Look up the namespace URI associated to the given prefix, starting from this node.
See for details on the algorithm used by this method.
Parameters:
prefix - The prefix to look for. If this parameter is null, the method will return the default namespace URI if any.
Returns:
Returns the associated namespace URI or null if none is found.
Since:
DOM Level 3

lookupPrefix

public String lookupPrefix(String namespaceURI)
Look up the prefix associated to the given namespace URI, starting from this node. The default namespace declarations are ignored by this method.
See for details on the algorithm used by this method.
Parameters:
namespaceURI - The namespace URI to look for.
Returns:
Returns an associated namespace prefix if found or null if none is found. If more than one prefix are associated to the namespace prefix, the returned namespace prefix is implementation dependent.
Since:
DOM Level 3

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.
Since:
DOM Level 2

outputNamespaceNodes

public void outputNamespaceNodes(Outputter out,
                                 boolean includeAncestors)
            throws TransformerException
Output all namespace nodes associated with this element. Does nothing if the node is not an element.
Specified by:
outputNamespaceNodes in interface NodeInfo
Parameters:
out - The relevant outputter
includeAncestors - True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree

removeAttribute

public void removeAttribute(String oldAttr)
            throws DOMException
Removes the specified attribute. Always fails

removeAttributeNS

public void removeAttributeNS(String namespaceURI,
                              String localName)
            throws DOMException
Removes an attribute by local name and namespace URI. Always fails
Since:
DOM Level 2

removeAttributeNode

public Attr removeAttributeNode(Attr oldAttr)
            throws DOMException
Removes the specified attribute node. Always fails

removeChild

public Node removeChild(Node oldChild)
            throws DOMException
Remove the child node indicated by oldChild from the list of children, and returns it. DOM method: always fails.
Parameters:
oldChild - The node being removed.
Returns:
The node removed.

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
            throws DOMException
Replace the child node oldChild with newChild in the list of children, and returns the oldChild node. Always fails.
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.

replaceData

public void replaceData(int offset,
                        int count,
                        String arg)
            throws DOMException
Replace the characters starting at the specified 16-bit unit offset with the specified string. DOM method: always fails.
Parameters:
offset - The offset from which to start replacing.
count - The number of 16-bit units to replace.
arg - The DOMString with which the range must be replaced.

replaceWholeText

public Text replaceWholeText(String content)
            throws DOMException
Replaces the text of the current node and all logically-adjacent text nodes with the specified text. All logically-adjacent text nodes are removed including the current node unless it was the recipient of the replacement text.
This method returns the node which received the replacement text. The returned node is:
  • null, when the replacement text is the empty string;
  • the current node, except when the current node is read-only;
  • a new Text node of the same type ( Text or CDATASection) as the current node inserted at the location of the replacement.

For instance, in the above example calling replaceWholeText on the Text node that contains "bar" with "yo" in argument results in the following:
Where the nodes to be removed are read-only descendants of an EntityReference, the EntityReference must be removed instead of the read-only nodes. If any EntityReference to be removed has descendants that are not EntityReference, Text, or CDATASection nodes, the replaceWholeText method must fail before performing any modification of the document, raising a DOMException with the code NO_MODIFICATION_ALLOWED_ERR.
For instance, in the example below calling replaceWholeText on the Text node that contains "bar" fails, because the EntityReference node "ent" contains an Element node which cannot be removed.
Parameters:
content - The content of the replacing Text node.
Returns:
The Text node created with the specified content.
Since:
DOM Level 3

setAttributeNS

public void setAttributeNS(String namespaceURI,
                           String qualifiedName,
                           String value)
            throws DOMException
Adds a new attribute. Always fails.
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.

setAttributeNode

public Attr setAttributeNode(Attr newAttr)
            throws DOMException
Adds a new attribute node. Always fails

setAttributeNodeNS

public Attr setAttributeNodeNS(Attr newAttr)
            throws DOMException
Add a new attribute. Always fails.
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.
Since:
DOM Level 2

setData

public void setData(String data)
            throws DOMException
Set the character data of a Text or Comment node. DOM method: always fails, Saxon tree is immutable.

setIdAttribute

public void setIdAttribute(String name,
                           boolean isId)
            throws DOMException
If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute . This affects the value of Attr.isId and the behavior of Document.getElementById, but does not change any schema that may be in use, in particular this does not affect the Attr.schemaTypeInfo of the specified Attr node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.
To specify an attribute by local name and namespace URI, use the setIdAttributeNS method.
Parameters:
name - The name of the attribute.
isId - Whether the attribute is a of type ID.
Since:
DOM Level 3

setIdAttributeNS

public void setIdAttributeNS(String namespaceURI,
                             String localName,
                             boolean isId)
            throws DOMException
If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute . This affects the value of Attr.isId and the behavior of Document.getElementById, but does not change any schema that may be in use, in particular this does not affect the Attr.schemaTypeInfo of the specified Attr node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.
Parameters:
namespaceURI - The namespace URI of the attribute.
localName - The local name of the attribute.
isId - Whether the attribute is a of type ID.
Since:
DOM Level 3

setIdAttributeNode

public void setIdAttributeNode(Attr idAttr,
                               boolean isId)
            throws DOMException
If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute . This affects the value of Attr.isId and the behavior of Document.getElementById, but does not change any schema that may be in use, in particular this does not affect the Attr.schemaTypeInfo of the specified Attr node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.
Parameters:
idAttr - The attribute node.
isId - Whether the attribute is a of type ID.
Since:
DOM Level 3

setNodeValue

public void setNodeValue(String nodeValue)
            throws DOMException
Set the node value. DOM method: always fails

setPrefix

public void setPrefix(String prefix)
            throws DOMException
Set the namespace prefix of this node. Always fails.

setTextContent

public void setTextContent(String textContent)
            throws DOMException
This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced by a single Text node containing the string this attribute is set to.
On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attribute Text.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:
Node typeContent
ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODEconcatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODEnodeValue
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODEnull
Since:
DOM Level 3

setUserData

public Object setUserData(String key,
                          Object data,
                          org.w3c.dom.UserDataHandler handler)
Associate an object to a key on this node. The object can later be retrieved from this node by calling getUserData with the same key.
Parameters:
key - The key to associate the object to.
data - The object to associate to the given key, or null to remove any existing association to that key.
handler - The handler to associate to that key, or null.
Returns:
Returns the DOMUserData previously associated to the given key on this node, or null if there was none.
Since:
DOM Level 3

setValue

public void setValue(String value)
            throws DOMException
Set the value of an attribute node. (DOM method). Always fails (because tree is readonly)

splitText

public Text splitText(int offset)
            throws DOMException
Break this node into two nodes at the specified offset, keeping both in the tree as siblings. DOM method, always fails.
Parameters:
offset - The 16-bit unit offset at which to split, starting from 0.
Returns:
The new node, of the same type as this node.

substringData

public String substringData(int offset,
                            int count)
            throws DOMException
Extract a range of data from a Text or Comment node. DOM method.
Parameters:
offset - Start offset of substring to extract.
count - The number of 16-bit units to extract.
Returns:
The specified substring. If the sum of offset and count exceeds the length , then all 16-bit units to the end of the data are returned.

supports

public boolean supports(String feature,
                        String version)
Alternative to isSupported(), defined in a draft DOM spec