net.sf.saxon.dom
Class NodeOverNodeInfo

java.lang.Object
  extended bynet.sf.saxon.dom.NodeOverNodeInfo
All Implemented Interfaces:
org.w3c.dom.Node
Direct Known Subclasses:
AttrOverNodeInfo, DocumentOverNodeInfo, ElementOverNodeInfo, PIOverNodeInfo, TextOverNodeInfo

public abstract class NodeOverNodeInfo
extends java.lang.Object
implements org.w3c.dom.Node

This class implements the DOM Node interface as a wrapper around a Saxon NodeInfo object


Field Summary
protected  NodeInfo node
           
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
NodeOverNodeInfo()
           
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          Adds the node newChild to the end of the list of children of this node.
 org.w3c.dom.Node cloneNode(boolean deep)
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 short compareDocumentPosition(org.w3c.dom.Node other)
          Compare the position of the (other) node in document order with the reference node (this node).
protected static void disallowUpdate()
          Internal method used to indicate that update operations are not allowed
 org.w3c.dom.NamedNodeMap getAttributes()
          Return a NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise.
 java.lang.String getBaseURI()
          Get the base URI for the node.
 org.w3c.dom.NodeList getChildNodes()
          Return a NodeList that contains all children of this node.
 org.w3c.dom.Element getDocumentElement()
          Get the outermost element.
 java.lang.Object getFeature(java.lang.String feature, java.lang.String version)
          Get a feature of this node.
 org.w3c.dom.Node getFirstChild()
          Get first child (DOM method)
 org.w3c.dom.Node getLastChild()
          Get last child (DOM method)
 java.lang.String getLocalName()
          Get the local name of this node, following the DOM rules
 java.lang.String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 org.w3c.dom.Node getNextSibling()
          Get next sibling node (DOM method)
 java.lang.String getNodeName()
          Get the name of this node, following the DOM rules
 short getNodeType()
          Get the type of this node (DOM method).
 java.lang.String getNodeValue()
          Get the node value as defined in the DOM.
 org.w3c.dom.Document getOwnerDocument()
          Return the Document object associated with this node.
 org.w3c.dom.Node getParentNode()
          Find the parent node of this node (DOM method).
 java.lang.String getPrefix()
          The namespace prefix of this node, or null if it is unspecified.
 org.w3c.dom.Node getPreviousSibling()
          Get the previous sibling of the node (DOM method)
 java.lang.String getTextContent()
          Get the text content of a node.
 NodeInfo getUnderlyingNodeInfo()
           
 java.lang.Object getUserData(java.lang.String key)
          Get user data associated with this node.
 boolean hasAttributes()
          Returns whether this node has any attributes.
 boolean hasChildNodes()
          Determine whether the node has any children.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Insert the node newChild before the existing child node refChild.
 boolean isDefaultNamespace(java.lang.String namespaceURI)
          Test whether a particular namespace is the default namespace.
 boolean isEqualNode(org.w3c.dom.Node arg)
          Compare whether two nodes have the same content.
 boolean isId()
          Determine whether this (attribute) node is an ID.
 boolean isSameNode(org.w3c.dom.Node other)
          Determine whether this is the same node as another node.
 boolean isSupported(java.lang.String feature, java.lang.String version)
          Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
 java.lang.String lookupNamespaceURI(java.lang.String prefix)
          Find the URI corresponding to a given in-scope prefix
 java.lang.String lookupPrefix(java.lang.String namespaceURI)
          Get the (first) prefix assigned to a specified namespace URI, or null if the namespace is not in scope.
 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.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Remove the child node indicated by oldChild from the list of children, and returns it.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replace the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setNodeValue(java.lang.String nodeValue)
          Set the node value.
 void setPrefix(java.lang.String prefix)
          Set the namespace prefix of this node.
 void setTextContent(java.lang.String textContent)
          Set the text content of a node.
 void setUnderlyingNodeInfo(NodeInfo node)
           
 java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
          Set user data.
 boolean supports(java.lang.String feature, java.lang.String version)
          Alternative to isSupported(), defined in a draft DOM spec
static NodeOverNodeInfo wrap(NodeInfo node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

protected NodeInfo node
Constructor Detail

NodeOverNodeInfo

public NodeOverNodeInfo()
Method Detail

getUnderlyingNodeInfo

public NodeInfo getUnderlyingNodeInfo()

setUnderlyingNodeInfo

public void setUnderlyingNodeInfo(NodeInfo node)

wrap

public static NodeOverNodeInfo wrap(NodeInfo node)

isSameNode

public final boolean isSameNode(org.w3c.dom.Node other)
Determine whether this is the same node as another node. DOM Level 3 method.

Returns:
true if this Node object and the supplied Node object represent the same node in the tree.

getBaseURI

public java.lang.String getBaseURI()
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.


getNodeName

public java.lang.String getNodeName()
Get the name of this node, following the DOM rules

Specified by:
getNodeName in interface org.w3c.dom.Node
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"

getLocalName

public java.lang.String getLocalName()
Get the local name of this node, following the DOM rules

Specified by:
getLocalName in interface org.w3c.dom.Node
Returns:
The local 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"

isId

public boolean isId()
Determine whether this (attribute) node is an ID. This method is introduced in DOM Level 3. The current implementation is simplistic; it returns true if the type annotation of the node is xs:ID (subtypes not allowed).


hasChildNodes

public boolean hasChildNodes()
Determine whether the node has any children.

Specified by:
hasChildNodes in interface org.w3c.dom.Node
Returns:
true if this node has any attributes, false otherwise.

hasAttributes

public boolean hasAttributes()
Returns whether this node has any attributes.

Specified by:
hasAttributes in interface org.w3c.dom.Node
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2

getNodeType

public short getNodeType()
Get the type of this node (DOM method). Note, the numbers assigned to node kinds in Saxon (see module Type) are the same as those assigned in the DOM

Specified by:
getNodeType in interface org.w3c.dom.Node

getParentNode

public org.w3c.dom.Node getParentNode()
Find the parent node of this node (DOM method).

Specified by:
getParentNode in interface org.w3c.dom.Node
Returns:
The Node object describing the containing element or root node.

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Get the previous sibling of the node (DOM method)

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

getNextSibling

public org.w3c.dom.Node getNextSibling()
Get next sibling node (DOM method)

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

getFirstChild

public org.w3c.dom.Node getFirstChild()
Get first child (DOM method)

Specified by:
getFirstChild in interface org.w3c.dom.Node
Returns:
the first child node of this node, or null if it has no children

getLastChild

public org.w3c.dom.Node getLastChild()
Get last child (DOM method)

Specified by:
getLastChild in interface org.w3c.dom.Node
Returns:
last child of this node, or null if it has no children

getDocumentElement

public org.w3c.dom.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 first element child of the root if there is one, otherwise null.

getNodeValue

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

Specified by:
getNodeValue in interface org.w3c.dom.Node

setNodeValue

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

Specified by:
setNodeValue in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getChildNodes

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

Specified by:
getChildNodes in interface org.w3c.dom.Node

getAttributes

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

Specified by:
getAttributes in interface org.w3c.dom.Node

getOwnerDocument

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

Specified by:
getOwnerDocument in interface org.w3c.dom.Node

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
Insert the node newChild before the existing child node refChild. DOM method: always fails.

Specified by:
insertBefore in interface org.w3c.dom.Node
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
                              throws org.w3c.dom.DOMException
Replace the child node oldChild with newChild in the list of children, and returns the oldChild node. Always fails.

Specified by:
replaceChild in interface org.w3c.dom.Node
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
Remove the child node indicated by oldChild from the list of children, and returns it. DOM method: always fails.

Specified by:
removeChild in interface org.w3c.dom.Node
Parameters:
oldChild - The node being removed.
Returns:
The node removed.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Always raised.

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
Adds the node newChild to the end of the list of children of this node. DOM method: always fails.

Specified by:
appendChild in interface org.w3c.dom.Node
Parameters:
newChild - The node to add.
Returns:
The node added.
Throws:
org.w3c.dom.DOMException -
NO_MODIFICATION_ALLOWED_ERR: Always raised.

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent. Not implemented: always returns null. (Because trees are read-only, there would be no way of using the resulting node.)

Specified by:
cloneNode in interface org.w3c.dom.Node
Parameters:
deep - If true , recursively clone the subtree under the specified node; if false , clone only the node itself (and its attributes, if it is an Element ).
Returns:
The duplicate node.

normalize

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

Specified by:
normalize in interface org.w3c.dom.Node
Since:
DOM Level 2

isSupported

public boolean isSupported(java.lang.String feature,
                           java.lang.String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

Specified by:
isSupported in interface org.w3c.dom.Node
Parameters:
feature - The name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation .
version - This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true .
Returns:
Returns true if the specified feature is supported on this node, false otherwise.
Since:
DOM Level 2

supports

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


getNamespaceURI

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

Specified by:
getNamespaceURI in interface org.w3c.dom.Node
Since:
DOM Level 2

getPrefix

public java.lang.String getPrefix()
The namespace prefix of this node, or null if it is unspecified.
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.

Specified by:
getPrefix in interface org.w3c.dom.Node
Since:
DOM Level 2

setPrefix

public void setPrefix(java.lang.String prefix)
               throws org.w3c.dom.DOMException
Set the namespace prefix of this node. Always fails.

Specified by:
setPrefix in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

compareDocumentPosition

public short compareDocumentPosition(org.w3c.dom.Node other)
                              throws org.w3c.dom.DOMException
Compare the position of the (other) node in document order with the reference node (this node). DOM Level 3 method.

Parameters:
other - the other node.
Returns:
-1 (this node is first), 0 (same node), +1 (other node is first)
Throws:
org.w3c.dom.DOMException

getTextContent

public java.lang.String getTextContent()
                                throws org.w3c.dom.DOMException
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.

Returns:
the string value of the node, or null in the case of document nodes.
Throws:
org.w3c.dom.DOMException

setTextContent

public void setTextContent(java.lang.String textContent)
                    throws org.w3c.dom.DOMException
Set the text content of a node. DOM Level 3 method, not supported.

Parameters:
textContent -
Throws:
org.w3c.dom.DOMException

lookupPrefix

public java.lang.String lookupPrefix(java.lang.String namespaceURI)
Get the (first) prefix assigned to a specified namespace URI, or null if the namespace is not in scope. DOM Level 3 method.

Parameters:
namespaceURI - the namespace whose prefix is required
Returns:
the corresponding prefix

isDefaultNamespace

public boolean isDefaultNamespace(java.lang.String namespaceURI)
Test whether a particular namespace is the default namespace. DOM Level 3 method.

Parameters:
namespaceURI - the namespace to be tested
Returns:
true if this is the default namespace

lookupNamespaceURI

public java.lang.String lookupNamespaceURI(java.lang.String prefix)
Find the URI corresponding to a given in-scope prefix

Parameters:
prefix - The namespace prefix whose namespace URI is required.
Returns:
the corresponding namespace URI, or null if the prefix is not declared.

isEqualNode

public boolean isEqualNode(org.w3c.dom.Node arg)
Compare whether two nodes have the same content. This is a DOM Level 3 method; the implementation uses the same algorithm as the XPath deep-equals() function.

Parameters:
arg - The node to be compared. This must wrap a Saxon NodeInfo.
Returns:
true if the two nodes are deep-equal.

getFeature

public java.lang.Object getFeature(java.lang.String feature,
                                   java.lang.String version)
Get a feature of this node. DOM Level 3 method, always returns null.

Parameters:
feature - the required feature
version - the version of the required feature
Returns:
the value of the feature. Always null in this implementation

setUserData

public java.lang.Object setUserData(java.lang.String key,
                                    java.lang.Object data,
                                    org.w3c.dom.UserDataHandler handler)
Set user data. Always throws UnsupportedOperationException in this implementation

Parameters:
key -
data -
handler -
Returns:
This implementation always throws an exception

getUserData

public java.lang.Object getUserData(java.lang.String key)
Get user data associated with this node. DOM Level 3 method, always returns null in this implementation

Parameters:
key - identifies the user data required
Returns:
always null in this implementation

disallowUpdate

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

Throws:
org.w3c.dom.DOMException