org.apache.servicemix.common.util
Class DOMUtil

java.lang.Object
  extended by org.apache.servicemix.common.util.DOMUtil

public final class DOMUtil
extends java.lang.Object

A collection of W3C DOM helper methods

Version:
$Revision: 564607 $

Method Summary
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)
          Get the first child element
static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element el)
          Get the next sibling element
static javax.xml.namespace.QName getQName(org.w3c.dom.Element el)
          Build 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()
          Return 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getElementText

public static java.lang.String getElementText(org.w3c.dom.Element element)
Returns the text of the element


moveContent

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


copyAttributes

public static void copyAttributes(org.w3c.dom.Element from,
                                  org.w3c.dom.Element to)
Copy the attribues on one element to the other


asXML

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

Throws:
javax.xml.transform.TransformerException

asIndentedXML

public 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

Throws:
javax.xml.transform.TransformerException

addChildElement

public static void addChildElement(org.w3c.dom.Element element,
                                   java.lang.String name,
                                   java.lang.Object textValue)
Adds the child element with the given text


createQName

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

Parameters:
element - the element to use as the namespace context
qualifiedName - the fully qualified name
Returns:
the QName which matches the qualifiedName

recursiveGetAttributeValue

public static java.lang.String recursiveGetAttributeValue(org.w3c.dom.Element element,
                                                          java.lang.String attributeName)
Recursive method to find a given attribute value


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node parent)
Get the first child element

Parameters:
parent -
Returns:

getNextSiblingElement

public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element el)
Get the next sibling element

Parameters:
el -
Returns:

getQName

public static javax.xml.namespace.QName getQName(org.w3c.dom.Element el)
Build a QName from the element name

Parameters:
el -
Returns:

getBuilder

public static javax.xml.parsers.DocumentBuilder getBuilder()
                                                    throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

releaseBuilder

public static void releaseBuilder(javax.xml.parsers.DocumentBuilder builder)

newDocument

public static org.w3c.dom.Document newDocument()
                                        throws javax.xml.parsers.ParserConfigurationException
Return a new document, ready to populate.

Returns:
Throws:
javax.xml.parsers.ParserConfigurationException


Copyright © 2005-2011 FuseSource. All Rights Reserved.