Top Description Constructors Methods
com.sun.org.apache.xml.internal.utils

public final Class DOM2Helper

extends Object
Class Inheritance
Imports
com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy, org.w3c.dom.Attr, .NamedNodeMap, .Node

This class provides a DOM level 2 "helper", which provides several services. The original class extended DOMHelper that was deprecated and then removed.

Constructor Summary

AccessConstructor and Description
private
DOM2Helper()

Construct an instance.

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

String containing the local name, or null if the node was not assigned a Namespace.
getLocalNameOfNode
(Node
Node to be examined
n
)

Returns the local name of the given node, as defined by the XML Namespaces specification.

private static String

Returns:

String containing the Local Name
getLocalNameOfNodeFallback
(Node
the node to be examined.
n
)

Returns the local name of the given node.

public static String

Returns:

String containing the Namespace URI bound to this DOM node at the time the Node was created.
getNamespaceOfNode
(Node
Node to be examined
n
)

Returns the Namespace Name (Namespace URI) for the given node.

public static Node

Returns:

the DOM parent of the input node, if there is one, or the ownerElement if the input node is an Attr, or null if the node is a Document, a DocumentFragment, or an orphan.
getParentOfNode
(Node
Node to be examined
node
)

Get the XPath-model parent of a node.

public static boolean

Returns:

false if node2 comes before node1, otherwise return true. You can think of this as (node1.documentOrderPosition <= node2.documentOrderPosition).
isNodeAfter
(Node
DOM Node to perform position comparison on.
node1
,
Node
DOM Node to perform position comparison on .
node2
)

Figure out whether node2 should be considered as being later in the document than node1, in Document Order as defined by the XPath model.

private static boolean

Returns:

true if child 2 is after child1 in document order.
isNodeAfterSibling
(Node
Must be the parent of both child1 and child2.
parent
,
Node
Must be the child of parent and not equal to child2.
child1
,
Node
Must be the child of parent and not equal to child1.
child2
)

Figure out if child2 is after child1 in document order.

public static boolean

Returns:

true if the two nodes are the same.
isNodeTheSame
(Node
The first DOM node to compare.
node1
,
Node
The second DOM node to compare.
node2
)

Use DTMNodeProxy to determine whether two nodes are the same.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DOM2Helperback to summary
private DOM2Helper()

Construct an instance.

Method Detail

getLocalNameOfNodeback to summary
public static String getLocalNameOfNode(Node n)

Returns the local name of the given node, as defined by the XML Namespaces specification. This is prepared to handle documents built using DOM Level 1 methods by falling back upon explicitly parsing the node name.

Parameters
n:Node

Node to be examined

Returns:String

String containing the local name, or null if the node was not assigned a Namespace.

getLocalNameOfNodeFallbackback to summary
private static String getLocalNameOfNodeFallback(Node n)

Returns the local name of the given node. If the node's name begins with a namespace prefix, this is the part after the colon; otherwise it's the full node name. This method is copied from com.sun.org.apache.xml.internal.utils.DOMHelper

Parameters
n:Node

the node to be examined.

Returns:String

String containing the Local Name

getNamespaceOfNodeback to summary
public static String getNamespaceOfNode(Node n)

Returns the Namespace Name (Namespace URI) for the given node. In a Level 2 DOM, you can ask the node itself. Note, however, that doing so conflicts with our decision in getLocalNameOfNode not to trust the that the DOM was indeed created using the Level 2 methods. If Level 1 methods were used, these two functions will disagree with each other.

Todo

Reconcile with getLocalNameOfNode.

Parameters
n:Node

Node to be examined

Returns:String

String containing the Namespace URI bound to this DOM node at the time the Node was created.

getParentOfNodeback to summary
public static Node getParentOfNode(Node node)

Get the XPath-model parent of a node. This version takes advantage of the DOM Level 2 Attr.ownerElement() method; the base version we would otherwise inherit is prepared to fall back on exhaustively walking the document to find an Attr's parent.

Parameters
node:Node

Node to be examined

Returns:Node

the DOM parent of the input node, if there is one, or the ownerElement if the input node is an Attr, or null if the node is a Document, a DocumentFragment, or an orphan.

isNodeAfterback to summary
public static boolean isNodeAfter(Node node1, Node node2)

Figure out whether node2 should be considered as being later in the document than node1, in Document Order as defined by the XPath model. This may not agree with the ordering defined by other XML applications.

There are some cases where ordering isn't defined, and neither are the results of this function -- though we'll generally return true.

Parameters
node1:Node

DOM Node to perform position comparison on.

node2:Node

DOM Node to perform position comparison on .

Returns:boolean

false if node2 comes before node1, otherwise return true. You can think of this as (node1.documentOrderPosition <= node2.documentOrderPosition).

isNodeAfterSiblingback to summary
private static boolean isNodeAfterSibling(Node parent, Node child1, Node child2)

Figure out if child2 is after child1 in document order.

Warning

Some aspects of "document order" are not well defined. For example, the order of attributes is considered meaningless in XML, and the order reported by our model will be consistent for a given invocation but may not match that of either the source file or the serialized output.

Parameters
parent:Node

Must be the parent of both child1 and child2.

child1:Node

Must be the child of parent and not equal to child2.

child2:Node

Must be the child of parent and not equal to child1.

Returns:boolean

true if child 2 is after child1 in document order.

isNodeTheSameback to summary
public static boolean isNodeTheSame(Node node1, Node node2)

Use DTMNodeProxy to determine whether two nodes are the same.

Parameters
node1:Node

The first DOM node to compare.

node2:Node

The second DOM node to compare.

Returns:boolean

true if the two nodes are the same.