Package net.sf.saxon.dom
Class NodeOverNodeInfo
java.lang.Object
net.sf.saxon.dom.NodeOverNodeInfo
- All Implemented Interfaces:
Node
- Direct Known Subclasses:
AttrOverNodeInfo,DocumentOverNodeInfo,ElementOverNodeInfo,PIOverNodeInfo,TextOverNodeInfo
This class implements the DOM Node interface as a wrapper around a Saxon NodeInfo object.
The class provides read-only access to the tree; methods that request updates all fail with an UnsupportedOperationException.
-
Field Summary
FieldsFields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendChild(Node newChild) Adds the nodenewChildto the end of the list of children of this node.cloneNode(boolean deep) Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.shortcompareDocumentPosition(Node other) Compare the position of the (other) node in document order with the reference node (this node).protected static voidInternal method used to indicate that update operations are not allowedbooleanThe equals() method returns true for two Node objects that represent the same conceptual DOM Node.Return aNamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise.Get the base URI for the node.Return aNodeListthat contains all children of this node.getFeature(String feature, String version) Get a feature of this node.Get first childGet last childGet the local name of this node, following the DOM rulesThe namespace URI of this node, ornullif it is unspecified.Get next sibling nodeGet the name of this node, following the DOM rulesshortGet the type of this node (node kind, in XPath terminology).Get the node value (as defined in the DOM).Return theDocumentobject associated with this node.Find the parent node of this node.The namespace prefix of this node, ornullif it is unspecified.Get the previous sibling of the nodeGet the text content of a node.Get the Saxon NodeInfo object representing this nodegetUserData(String key) Get user data associated with this node.booleanReturns whether this node has any attributes.booleanDetermine whether the node has any children.inthashCode()Return a hashCodeinsertBefore(Node newChild, Node refChild) Insert the nodenewChildbefore the existing child noderefChild.booleanisDefaultNamespace(String namespaceURI) Test whether a particular namespace is the default namespace.booleanisEqualNode(Node arg) Compare whether two nodes have the same content.final booleanisSameNode(Node other) Determine whether this is the same node as another node.booleanisSupported(String feature, String version) Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.lookupNamespaceURI(String prefix) Find the URI corresponding to a given in-scope prefixlookupPrefix(String namespaceURI) Get the (first) prefix assigned to a specified namespace URI, or null if the namespace is not in scope.voidPuts allTextnodes 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) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes.removeChild(Node oldChild) Remove the child node indicated byoldChildfrom the list of children, and returns it.replaceChild(Node newChild, Node oldChild) Replace the child nodeoldChildwithnewChildin the list of children, and returns theoldChildnode.voidsetNodeValue(String nodeValue) Set the node value.voidSet the namespace prefix of this node.voidsetTextContent(String textContent) Set the text content of a node.setUserData(String key, Object data, UserDataHandler handler) Set user data.static NodeOverNodeInfoFactory method to construct a DOM node that wraps an underlying Saxon NodeInfo
-
Field Details
-
node
-
-
Constructor Details
-
NodeOverNodeInfo
public NodeOverNodeInfo()
-
-
Method Details
-
getUnderlyingNodeInfo
Get the Saxon NodeInfo object representing this node- Returns:
- the Saxon NodeInfo object
-
wrap
Factory method to construct a DOM node that wraps an underlying Saxon NodeInfo- Parameters:
node- the Saxon NodeInfo object- Returns:
- the DOM wrapper node
-
isSameNode
Determine whether this is the same node as another node. DOM Level 3 method.- Specified by:
isSameNodein interfaceNode- Returns:
- true if this Node object and the supplied Node object represent the same node in the tree.
-
equals
The equals() method returns true for two Node objects that represent the same conceptual DOM Node. This is a concession to the Xalan IdentityTransformer, which relies on equals() for DOM Nodes having this behaviour, even though it is not defined in the specification -
hashCode
public int hashCode()Return a hashCode -
getBaseURI
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.- Specified by:
getBaseURIin interfaceNode
-
getNodeName
Get the name of this node, following the DOM rules- Specified by:
getNodeNamein interfaceNode- Returns:
- The name of the node. For an element this is the element name, for an attribute it is the attribute name, as a lexical QName. Other node types return conventional names such as "#text" or "#comment"
-
getLocalName
Get the local name of this node, following the DOM rules- Specified by:
getLocalNamein interfaceNode- Returns:
- The local name of the node. For an element this is the local part of the element name, for an attribute it is the local part of the attribute name. Other node types return null.
-
hasChildNodes
public boolean hasChildNodes()Determine whether the node has any children.- Specified by:
hasChildNodesin interfaceNode- Returns:
trueif this node has any attributes,falseotherwise.
-
hasAttributes
public boolean hasAttributes()Returns whether this node has any attributes. We treat the declaration of the XML namespace as being present on every element, and since namespace declarations are treated as attributes, every element has at least one attribute. This method therefore returns true.- Specified by:
hasAttributesin interfaceNode- Returns:
trueif this node has any attributes,falseotherwise.- Since:
- DOM Level 2
-
getNodeType
public short getNodeType()Get the type of this node (node kind, in XPath terminology). Note, the numbers assigned to node kinds in Saxon (seeType) are the same as those assigned in the DOM- Specified by:
getNodeTypein interfaceNode
-
getParentNode
Find the parent node of this node.- Specified by:
getParentNodein interfaceNode- Returns:
- The Node object describing the containing element or root node.
-
getPreviousSibling
Get the previous sibling of the node- Specified by:
getPreviousSiblingin interfaceNode- Returns:
- The previous sibling node. Returns null if the current node is the first child of its parent.
-
getNextSibling
Get next sibling node- Specified by:
getNextSiblingin interfaceNode- Returns:
- The next sibling node. Returns null if the current node is the last child of its parent.
-
getFirstChild
Get first child- Specified by:
getFirstChildin interfaceNode- Returns:
- the first child node of this node, or null if it has no children
-
getLastChild
Get last child- Specified by:
getLastChildin interfaceNode- Returns:
- last child of this node, or null if it has no children
-
getNodeValue
Get the node value (as defined in the DOM). This is not generally the same as the XPath string-value: in particular, the node value of an element node is null.- Specified by:
getNodeValuein interfaceNode
-
setNodeValue
Set the node value. Always fails- Specified by:
setNodeValuein interfaceNode- Throws:
DOMException
-
getChildNodes
Return aNodeListthat contains all children of this node. If there are no children, this is aNodeListcontaining no nodes.- Specified by:
getChildNodesin interfaceNode
-
getAttributes
Return aNamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise.- Specified by:
getAttributesin interfaceNode
-
getOwnerDocument
Return theDocumentobject associated with this node.- Specified by:
getOwnerDocumentin interfaceNode
-
insertBefore
Insert the nodenewChildbefore the existing child noderefChild. Always fails.- Specified by:
insertBeforein interfaceNode- 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:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Always raised.
-
replaceChild
Replace the child nodeoldChildwithnewChildin the list of children, and returns theoldChildnode. Always fails.- Specified by:
replaceChildin interfaceNode- Parameters:
newChild- The new node to put in the child list.oldChild- The node being replaced in the list.- Returns:
- The node replaced.
- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Always raised.
-
removeChild
Remove the child node indicated byoldChildfrom the list of children, and returns it. Always fails.- Specified by:
removeChildin interfaceNode- Parameters:
oldChild- The node being removed.- Returns:
- The node removed.
- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Always raised.
-
appendChild
Adds the nodenewChildto the end of the list of children of this node. Always fails.- Specified by:
appendChildin interfaceNode- Parameters:
newChild- The node to add.- Returns:
- The node added.
- Throws:
DOMException-
NO_MODIFICATION_ALLOWED_ERR: Always raised.
-
cloneNode
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. Always fails. -
normalize
public void normalize()Puts allTextnodes 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) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes. -
isSupported
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.- Specified by:
isSupportedin interfaceNode- Parameters:
feature- The name of the feature to test. This is the same name which can be passed to the methodhasFeatureonDOMImplementation.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
trueif the specified feature is supported on this node,falseotherwise. - Since:
- DOM Level 2
-
getNamespaceURI
The namespace URI of this node, ornullif 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 thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such ascreateElementfrom theDocumentinterface, 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.- Specified by:
getNamespaceURIin interfaceNode- Since:
- DOM Level 2
-
getPrefix
The namespace prefix of this node, ornullif it is unspecified.
For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such ascreateElementfrom theDocumentinterface, this is alwaysnull. -
setPrefix
Set the namespace prefix of this node. Always fails.- Specified by:
setPrefixin interfaceNode- Throws:
DOMException
-
compareDocumentPosition
Compare the position of the (other) node in document order with the reference node (this node). DOM Level 3 method.- Specified by:
compareDocumentPositionin interfaceNode- Parameters:
other- the other node.- Returns:
- Returns how the node is positioned relatively to the reference node.
- Throws:
DOMException- if an error occurs
-
getTextContent
Get the text content of a node. This is a DOM Level 3 method. The definition is the same as the definition of the string value of a node in XPath, except in the case of document nodes.- Specified by:
getTextContentin interfaceNode- Returns:
- the string value of the node, or null in the case of document nodes.
- Throws:
DOMException- if a dynamic error occurs
-
setTextContent
Set the text content of a node. Always fails.- Specified by:
setTextContentin interfaceNode- Parameters:
textContent- the new text content of the node- Throws:
UnsupportedOperationException- always
-
lookupPrefix
Get the (first) prefix assigned to a specified namespace URI, or null if the namespace is not in scope. DOM Level 3 method.- Specified by:
lookupPrefixin interfaceNode- Parameters:
namespaceURI- the namespace whose prefix is required- Returns:
- the corresponding prefix, if there is one, or null if not.
-
isDefaultNamespace
Test whether a particular namespace is the default namespace. DOM Level 3 method.- Specified by:
isDefaultNamespacein interfaceNode- Parameters:
namespaceURI- the namespace to be tested- Returns:
- true if this is the default namespace
-
lookupNamespaceURI
Find the URI corresponding to a given in-scope prefix- Specified by:
lookupNamespaceURIin interfaceNode- Parameters:
prefix- The namespace prefix whose namespace URI is required.- Returns:
- the corresponding namespace URI, or null if the prefix is not declared.
-
isEqualNode
Compare whether two nodes have the same content. This is a DOM Level 3 method.- Specified by:
isEqualNodein interfaceNode- Parameters:
arg- The node to be compared. This must wrap a Saxon NodeInfo.- Returns:
- true if the two nodes are deep-equal.
-
getFeature
Get a feature of this node. DOM Level 3 method, always returns null.- Specified by:
getFeaturein interfaceNode- Parameters:
feature- the required featureversion- the version of the required feature- Returns:
- the value of the feature. Always null in this implementation
-
setUserData
Set user data. Always throws UnsupportedOperationException in this implementation- Specified by:
setUserDatain interfaceNode- Parameters:
key- name of the user datadata- value of the user datahandler- handler for the user data- Returns:
- This implementation always throws an exception
-
getUserData
Get user data associated with this node. DOM Level 3 method, always returns null in this implementation- Specified by:
getUserDatain interfaceNode- Parameters:
key- identifies the user data required- Returns:
- always null in this implementation
-
disallowUpdate
Internal method used to indicate that update operations are not allowed- Throws:
DOMException- always, to indicate that update is not supported in this DOM implementation
-