Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
com.icl.saxon.om.AbstractNode
public abstract class AbstractNode
extends java.lang.Object
implements Node, NodeInfo, SourceLocator, DOMLocator
Nested Class Summary |
Field Summary | |
static char[] |
|
Fields inherited from interface com.icl.saxon.om.NodeInfo | |
ATTRIBUTE , COMMENT , ELEMENT , NAMESPACE , NODE , NONE , NUMBER_OF_TYPES , PI , ROOT , TEXT |
Method Summary | |
Node |
|
void |
|
Node |
|
int |
|
void |
|
Attr |
|
Attr |
|
CDATASection |
|
Comment |
|
DocumentFragment |
|
Element |
|
Element |
|
EntityReference |
|
ProcessingInstruction |
|
Text |
|
void |
|
protected void |
|
String |
|
String |
|
String |
|
Attr |
|
Attr |
|
String |
|
String |
|
NamedNodeMap |
|
String |
|
NodeList |
|
int |
|
String |
|
String |
|
DocumentType |
|
Element |
|
DocumentInfo |
|
Element |
|
NodeList |
|
NodeList |
|
AxisEnumeration |
|
int |
|
Node |
|
DOMImplementation |
|
Node |
|
int |
|
int |
|
String |
|
String |
|
int |
|
String |
|
Node |
|
String |
|
String |
|
Node |
|
Document |
|
Element |
|
NodeInfo |
|
Node |
|
String |
|
Node |
|
String |
|
boolean |
|
String |
|
String |
|
String |
|
String |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Node |
|
Node |
|
void |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
Attr |
|
Node |
|
Node |
|
void |
|
void |
|
Attr |
|
Attr |
|
void |
|
void |
|
void |
|
void |
|
Text |
|
String |
|
boolean |
|
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()
public Node appendChild(Node newChild) throws DOMException
Adds the nodenewChild
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.
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
- TheDOMString
to append.
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
- Iftrue
, recursively clone the subtree under the specified node; iffalse
, clone only the node itself (and its attributes, if it is anElement
).
- Returns:
- The duplicate node.
public 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())
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
public Attr createAttribute(String name) throws DOMException
Create anAttr
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 thenodeName
attribute set toname
, andlocalName
,prefix
, andnamespaceURI
set tonull
.
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.
public CDATASection createCDATASection(String data) throws DOMException
Create aCDATASection
node whose value is the specified string. DOM method: always fails, because the Saxon tree is not updateable.
- Parameters:
data
- The data for theCDATASection
contents.
- Returns:
- The new
CDATASection
object.
public Comment createComment(String data)
Create aComment
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.
public DocumentFragment createDocumentFragment()
Creates an emptyDocumentFragment
object.
- Returns:
- A new
DocumentFragment
. DOM method: returns null, because the Saxon tree is not updateable.
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.
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
public EntityReference createEntityReference(String name) throws DOMException
Create anEntityReference
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.
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
Create aProcessingInstruction
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.
public Text createTextNode(String data)
Create aText
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.
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.
protected void disallowUpdate() throws DOMException
Internal method used to indicate that update operations are not allowed
public String generateId()
Get a character string that uniquely identifies this node
- Specified by:
- generateId in interface NodeInfo
- Returns:
- a string.
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.
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
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 thegetAttributeNodeNS
method.
- Parameters:
name
- The name (nodeName
) of the attribute to retrieve.
- Returns:
- The
Attr
node with the specified name (nodeName
) ornull
if there is no such attribute.
public Attr getAttributeNodeNS(String namespaceURI, String localName)
Retrieves anAttr
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 ornull
if there is no such attribute.
- Since:
- DOM Level 2
public 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 attributelocalName
- the local name of an attribute
- Returns:
- the value of the attribute, if it exists, otherwise null
public 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
public NamedNodeMap getAttributes()
Return aNamedNodeMap
containing the attributes of this node (if it is anElement
) ornull
otherwise. (DOM method)
public 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
public NodeList getChildNodes()
Return aNodeList
that contains all children of this node. If there are no children, this is aNodeList
containing no nodes. DOM Method.
public int getColumnNumber()
Get the column number of the node. The default implementation returns -1, meaning unknown
public String getData()
Get the character data of a Text or Comment node. DOM method.
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.
public DocumentType getDoctype()
Get the Document Type Declaration (seeDocumentType
) associated with this document. For HTML documents as well as XML documents without a document type declaration this returnsnull
. DOM method.
- Returns:
- null: The Saxon tree model does not include the document type information.
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.
public DocumentInfo getDocumentRoot()
Get the root (document) node
- Specified by:
- getDocumentRoot in interface NodeInfo
- Returns:
- the DocumentInfo representing the containing document
public Element getElementById(String elementId)
Return theElement
whoseID
is given byelementId
. If no such element exists, returnsnull
. Behavior is not defined if more than one element has thisID
. 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 returnnull
.
- Parameters:
elementId
- The uniqueid
value for an element.
- Returns:
- The matching element, or null if there is none.
- Since:
- DOM Level 2
public NodeList getElementsByTagName(String tagname)
Return aNodeList
of all theElements
with a given tag name in the order in which they are encountered in a preorder traversal of theDocument
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 matchedElements
.
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
Return aNodeList
of all theElements
with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of theDocument
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 matchedElements
.
- Since:
- DOM Level 2
public 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:
nodeTest
- A pattern to be matched by the returned nodes
- Returns:
- a AxisEnumeration that scans the nodes reached by the axis in turn.
public int getFingerprint()
Get the fingerprint of the node, used for matching names
- Specified by:
- getFingerprint in interface NodeInfo
public Node getFirstChild()
Get first child (DOM method)
- Returns:
- the first child node of this node, or null if it has no children
public DOMImplementation getImplementation()
Get aDOMImplementation
object that handles this document. A DOM application may use objects from multiple implementations. DOM method.
public Node getLastChild()
Get last child (DOM method)
- Returns:
- last child of this node, or null if it has no children
public int getLength()
Get the length of a Text or Comment node. DOM method.
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
public 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.
public String getName()
Get the name of an attribute node (the QName) (DOM method)
public int getNameCode()
Get the name code of the node, used for displaying names
- Specified by:
- getNameCode in interface NodeInfo
public String getNamespaceURI()
The namespace URI of this node, ornull
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 thanELEMENT_NODE
andATTRIBUTE_NODE
and nodes created with a DOM Level 1 method, such ascreateElement
from theDocument
interface, this is alwaysnull
. 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
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.
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"
public String getNodeValue()
Get the node value as defined in the DOM. This is not necessarily the same as the XPath string-value.
public Node getOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator
public Document getOwnerDocument()
Return theDocument
object associated with this node. (DOM method)
public Element getOwnerElement()
TheElement
node this attribute is attached to ornull
if this attribute is not in use.
- Since:
- DOM Level 2
public NodeInfo getParent()
Find the parent node of this node.
- Returns:
- The Node object describing the containing element or root node.
public Node getParentNode()
Find the parent node of this node (DOM method).
- Returns:
- The Node object describing the containing element or root node.
public String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.
- Returns:
- the prefix part of the name. For an unnamed node, return "".
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.
public String getPublicId()
Get the public identifier of the document entity containing this node. The default implementation returns null, meaning unknown
public boolean getSpecified()
If this attribute was explicitly given a value in the original document, this istrue
; otherwise, it isfalse
. (DOM method)
- Returns:
- Always true in this implementation.
public String getSystemId()
Get the system ID for the entity containing the node.
- Specified by:
- getSystemId in interface NodeInfo
public String getTagName()
The name of the element (DOM interface).
public 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.
- 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.
public String getValue()
Return the character value of an attribute node (DOM method)
- Returns:
- the attribute value
public boolean hasAttribute(String name)
Returnstrue
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
public boolean hasAttributeNS(String namespaceURI, String localName)
Returnstrue
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
public boolean hasAttributes()
Returns whether this node has any attributes.
- Returns:
true
if this node has any attributes,false
otherwise.
- Since:
- DOM Level 2
public 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.
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
public Node insertBefore(Node newChild, Node refChild) throws DOMException
Insert the nodenewChild
before the existing child noderefChild
. 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.
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
- TheDOMString
to insert.
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.
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 methodhasFeature
onDOMImplementation
.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 returntrue
.
- Returns:
- Returns
true
if the specified feature is supported on this node,false
otherwise.
- Since:
- DOM Level 2
public void normalize()
Puts allText
nodes in the full depth of the sub-tree underneath thisNode
, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separatesText
nodes, i.e., there are neither adjacentText
nodes nor emptyText
nodes.
- Since:
- DOM Level 2
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 outputterincludeAncestors
- True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree
public void removeAttribute(String oldAttr) throws DOMException
Removes the specified attribute. Always fails
public void removeAttributeNS(String namespaceURI, String localName) throws DOMException
Removes an attribute by local name and namespace URI. Always fails
- Since:
- DOM Level 2
public Attr removeAttributeNode(Attr oldAttr) throws DOMException
Removes the specified attribute node. Always fails
public Node removeChild(Node oldChild) throws DOMException
Remove the child node indicated byoldChild
from the list of children, and returns it. DOM method: always fails.
- Parameters:
oldChild
- The node being removed.
- Returns:
- The node removed.
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
Replace the child nodeoldChild
withnewChild
in the list of children, and returns theoldChild
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.
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
- TheDOMString
with which the range must be replaced.
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.
public Attr setAttributeNode(Attr newAttr) throws DOMException
Adds a new attribute node. Always fails
public Attr setAttributeNodeNS(Attr newAttr) throws DOMException
Add a new attribute. Always fails.
- Parameters:
newAttr
- TheAttr
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 replacedAttr
node is returned, otherwisenull
is returned.
- Since:
- DOM Level 2
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.
public void setNodeValue(String nodeValue) throws DOMException
Set the node value. DOM method: always fails
public void setPrefix(String prefix) throws DOMException
Set the namespace prefix of this node. Always fails.
public void setValue(String value) throws DOMException
Set the value of an attribute node. (DOM method). Always fails (because tree is readonly)
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.
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
andcount
exceeds thelength
, then all 16-bit units to the end of the data are returned.
public boolean supports(String feature, String version)
Alternative to isSupported(), defined in a draft DOM spec