public class DomUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.util.Properties |
OUTPUT_PROPERTIES_INDENT |
| Modifier and Type | Method and Description |
|---|---|
static org.w3c.dom.Document |
createDocument(java.lang.String qualifiedName,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String namespaceUri)
Creates a new document.
|
static boolean |
getBooleanAttribute(org.w3c.dom.Element element,
java.lang.String attributeName)
Determines whether a specific boolean flag is set on an element.
|
static org.w3c.dom.Element |
getChildElementByTagName(org.w3c.dom.Element parentElement,
java.lang.String name)
Retrieves the first immediate child element of the specified element
whose name matches the provided
name parameter. |
static int |
getChildElementCountByTagName(org.w3c.dom.Element parentElement,
java.lang.String name)
Counts the number of immediate child elements of the specified element
whose names match the provided
name parameter. |
static org.w3c.dom.Element[] |
getChildElementsByTagName(org.w3c.dom.Element parentElement,
java.lang.String name)
Retrieves all immediate child elements of the specified element whose
names match the provided
name parameter. |
static javax.xml.parsers.DocumentBuilder |
getDocumentBuilder()
Retrieves a thread-specific
DocumentBuilder. |
static java.lang.String |
getElementText(org.w3c.dom.Element element)
Returns the text content of a DOM
Element. |
static javax.xml.transform.TransformerFactory |
getTransformerFactory()
Retrieves a thread-specific
TransformerFactory. |
static void |
save(org.w3c.dom.Document document,
java.io.OutputStream out,
java.util.Properties outputProperties)
Writes the
Document to the specified OutputStream. |
static void |
save(org.w3c.dom.Document document,
java.io.PrintWriter w,
java.util.Properties outputProperties)
Writes the
Document to the specified PrintWriter. |
static void |
setElementText(org.w3c.dom.Element element,
java.lang.String value)
Sets the text content of a DOM
Element. |
public static final java.util.Properties OUTPUT_PROPERTIES_INDENT
public static org.w3c.dom.Document createDocument(java.lang.String qualifiedName,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String namespaceUri)
qualifiedName - the qualified name of the document type to be
createdpublicId - the external subset public identifiersystemId - the external subset system identifiernamespaceUri - the namespace URI of the document element to createpublic static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
DocumentBuilder.
As it is a shared resource, the returned object should not be reconfigured in any fashion.DocumentBuilder serving the current thread.public static javax.xml.transform.TransformerFactory getTransformerFactory()
TransformerFactory.
As it is a shared resource, the returned object should not be reconfigured in any fashion.TransformerFactory serving the current thread.public static boolean getBooleanAttribute(org.w3c.dom.Element element,
java.lang.String attributeName)
element - The element to analyze.attributeName - The name of the boolean 'flag' attribute.public static org.w3c.dom.Element getChildElementByTagName(org.w3c.dom.Element parentElement,
java.lang.String name)
name parameter.parentElement - The element to search.name - The name of the child element.public static org.w3c.dom.Element[] getChildElementsByTagName(org.w3c.dom.Element parentElement,
java.lang.String name)
name parameter.parentElement - The element to search.name - The name of the child element.public static int getChildElementCountByTagName(org.w3c.dom.Element parentElement,
java.lang.String name)
name parameter.parentElement - The element to analyze.name - The name of the child element.public static java.lang.String getElementText(org.w3c.dom.Element element)
Element.element - The Element to analyze.public static void save(org.w3c.dom.Document document,
java.io.OutputStream out,
java.util.Properties outputProperties)
throws org.xml.sax.SAXException
Document to the specified OutputStream.document - the Documentout - the OutputStreamoutputProperties - output properties passed to XML transformerorg.xml.sax.SAXExceptionpublic static void save(org.w3c.dom.Document document,
java.io.PrintWriter w,
java.util.Properties outputProperties)
throws org.xml.sax.SAXException
Document to the specified PrintWriter.document - the Documentw - the PrintWriteroutputProperties - output properties passed to XML transformerorg.xml.sax.SAXExceptionpublic static void setElementText(org.w3c.dom.Element element,
java.lang.String value)
Element.element - The Element to modify.value - The new text value.