public final class DOMHelper extends Object
| Constructor and Description |
|---|
DOMHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendClone(Element parentElement,
Node o) |
static <T> List<T> |
asList(T node) |
static void |
ensureOwnership(Document ownerDocument,
Node node) |
static Map<String,String> |
getNamespaceMapping(Document document)
Parse namespace prefixes defined in the documents root element.
|
static Document |
getOwnerDocumentFor(Node documentOrElement) |
static int |
nodeHashCode(Node node)
hashCode() implementation that is compatible with equals().
|
static boolean |
nodesAreEqual(Node a,
Node b)
Implementation independent version of the Node.isEqualNode() method.
|
static void |
removeAllChildren(Element element)
Simply removes all child nodes.
|
static void |
removeAttribute(Attr attributeNode) |
static void |
removeNodes(Iterable<? extends Node> existingNodes) |
static Element |
renameElement(Element element,
String newName) |
static void |
replaceElement(Element previous,
Element newNode) |
static void |
setDocumentElement(Document document,
Element element)
Replace the current root element.
|
static void |
setOrRemoveAttribute(Element element,
String attributeName,
String value) |
static void |
setStringValue(Node newNode,
String value)
Set a text value to a node whether it is an element or an attribute.
|
static String |
toXMLString(XBProjector projector,
Node domNode) |
static void |
trim(Node domNode) |
public static Map<String,String> getNamespaceMapping(Document document)
document - source document.public static void setDocumentElement(Document document, Element element)
document - element - public static boolean nodesAreEqual(Node a, Node b)
nodeName, localName,
namespaceURI, prefix, nodeValue . This is: they are
both null, or they have the same length and are character for character
identical.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.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.DocumentType nodes to be equal, the following conditions must also be
satisfied:
publicId, systemId,
internalSubset.entities NamedNodeMaps are equal.notations NamedNodeMaps are equal.a - b - public static int nodeHashCode(Node node)
node - public static void setOrRemoveAttribute(Element element, String attributeName, String value)
element - attributeName - value - public static Element renameElement(Element element, String newName)
element - newName - public static void ensureOwnership(Document ownerDocument, Node node)
ownerDocument - node - public static Document getOwnerDocumentFor(Node documentOrElement)
documentOrElement - public static void trim(Node domNode)
domNode - public static <T> List<T> asList(T node)
node - public static void replaceElement(Element previous, Element newNode)
previous - newNode - public static void setStringValue(Node newNode, String value)
newNode - value - public static void removeAllChildren(Element element)
element - public static void removeAttribute(Attr attributeNode)
attributeNode - public static void appendClone(Element parentElement, Node o)
parentElement - o - public static void removeNodes(Iterable<? extends Node> existingNodes)
existingNodes - public static String toXMLString(XBProjector projector, Node domNode)
projector - domNode - Copyright © 2012-12-21-2017. All Rights Reserved.