public final class DOMUtil
extends java.lang.Object
A collection of W3C DOM helper methods.
| Modifier and Type | Method and Description |
|---|---|
static void |
addChildElement(org.w3c.dom.Element element,
java.lang.String name,
java.lang.Object textValue)
Adds the child element with the given text.
|
static java.lang.String |
asIndentedXML(org.w3c.dom.Node node)
A helper method useful for debugging and logging which will convert the given DOM node into XML text.
|
static java.lang.String |
asXML(org.w3c.dom.Node node)
A helper method useful for debugging and logging which will convert the given DOM node into XML text.
|
static void |
copyAttributes(org.w3c.dom.Element from,
org.w3c.dom.Element to)
Copy the attribues on one element to the other.
|
static javax.xml.namespace.QName |
createQName(org.w3c.dom.Element element,
java.lang.String qualifiedName)
Creates a QName instance from the given namespace context for the given qualifiedName.
|
static javax.xml.parsers.DocumentBuilder |
getBuilder() |
static java.lang.String |
getElementText(org.w3c.dom.Element element)
Returns the text of the element.
|
static org.w3c.dom.Element |
getFirstChildElement(org.w3c.dom.Node parent)
Gets the first child element.
|
static org.w3c.dom.Element |
getNextSiblingElement(org.w3c.dom.Element el)
Gets the next sibling element.
|
static javax.xml.namespace.QName |
getQName(org.w3c.dom.Element el)
Builds a QName from the element name.
|
static void |
moveContent(org.w3c.dom.Element from,
org.w3c.dom.Element to)
Moves the content of the given element to the given element.
|
static org.w3c.dom.Document |
newDocument()
Returns a new document, ready to populate.
|
static java.lang.String |
recursiveGetAttributeValue(org.w3c.dom.Element element,
java.lang.String attributeName)
Recursive method to find a given attribute value.
|
static void |
releaseBuilder(javax.xml.parsers.DocumentBuilder builder) |
public static java.lang.String getElementText(org.w3c.dom.Element element)
Returns the text of the element.
element - the element.public static void moveContent(org.w3c.dom.Element from,
org.w3c.dom.Element to)
Moves the content of the given element to the given element.
from - the source element.to - the destination element.public static void copyAttributes(org.w3c.dom.Element from,
org.w3c.dom.Element to)
Copy the attribues on one element to the other.
from - the source element.to - the destination element.public static java.lang.String asXML(org.w3c.dom.Node node)
throws javax.xml.transform.TransformerException
A helper method useful for debugging and logging which will convert the given DOM node into XML text.
node - the node.javax.xml.transform.TransformerExceptionpublic static java.lang.String asIndentedXML(org.w3c.dom.Node node)
throws javax.xml.transform.TransformerException
A helper method useful for debugging and logging which will convert the given DOM node into XML text.
node - the node.javax.xml.transform.TransformerExceptionpublic static void addChildElement(org.w3c.dom.Element element,
java.lang.String name,
java.lang.Object textValue)
Adds the child element with the given text.
element - the element where to add child.name - the child elenemt name.textValue - the child element text value.public static javax.xml.namespace.QName createQName(org.w3c.dom.Element element,
java.lang.String qualifiedName)
Creates a QName instance from the given namespace context for the given qualifiedName.
element - the element to use as the namespace context.qualifiedName - the fully qualified name.public static java.lang.String recursiveGetAttributeValue(org.w3c.dom.Element element,
java.lang.String attributeName)
Recursive method to find a given attribute value.
element - the element where to looking for attribute.attributeName - the attribute name to look for.public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node parent)
Gets the first child element.
parent - the parent node.public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element el)
Gets the next sibling element.
el - the base element.public static javax.xml.namespace.QName getQName(org.w3c.dom.Element el)
Builds a QName from the element name.
el - the element.public static javax.xml.parsers.DocumentBuilder getBuilder()
throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationExceptionpublic static void releaseBuilder(javax.xml.parsers.DocumentBuilder builder)
public static org.w3c.dom.Document newDocument()
throws javax.xml.parsers.ParserConfigurationException
Returns a new document, ready to populate.
javax.xml.parsers.ParserConfigurationExceptionCopyright © 2005-2014 FuseSource. All Rights Reserved.