public class DOMUtil
extends java.lang.Object
Constructor and Description |
---|
DOMUtil() |
Modifier and Type | Method and Description |
---|---|
static org.w3c.dom.Node |
alphabetiseChildNodes(org.w3c.dom.Node root)
Alphabetises the top level children of the node root.
|
static org.w3c.dom.Document |
createDocumentInstance()
Creates a new, namespace aware, Document node
|
static org.w3c.dom.Document |
createNamespacelessDocumentInstance()
Creates a new, namespace aware, Document node
|
static org.xml.sax.InputSource |
createUTF8InputSource(org.w3c.dom.Node node)
Converts a Document dom into an Input source with UTF-8 encoding
|
static org.xml.sax.InputSource |
createUTF8InputSource(java.lang.String xml)
Converts a XML String into an Input source with UTF-8 encoding
|
static java.lang.String |
formatXMLStringForDisplay(java.lang.String xml)
Formats a string of XML suitable for standard display (ie.
|
static java.lang.String |
formatXMLStringForDisplay(java.lang.String xml,
boolean omitDeclaration)
Formats a string of XML suitable for standard display (ie.
|
static org.w3c.dom.Document |
getDocumentFromString(java.lang.String xml)
Converts a xml String to a DOM Document
|
static org.w3c.dom.Document |
getNamespacelessDocumentFromDocument(org.w3c.dom.Document dom) |
static org.w3c.dom.Document |
getNamespacelessDocumentFromString(java.lang.String xml) |
static java.lang.String |
getNodeText(org.w3c.dom.Node node)
Extracts to text from the supplied node and it's children.
|
static java.lang.String |
getXMLStringFragmentFromNode(org.w3c.dom.Node node)
Takes the supplied node as the root of an xml document and converts it to a String representation.
|
static java.lang.String |
getXMLStringFragmentFromNode(org.w3c.dom.Node node,
boolean omitDeclaration)
Takes the supplied node as the root of an xml document and converts it to a String representation.
|
static java.lang.String |
getXMLStringFragmentFromNode(org.w3c.dom.Node node,
boolean omitDeclaration,
boolean collapseEmptyTags)
Takes the supplied node as the root of an xml document and converts it to a String representation.
|
static java.lang.String |
getXMLStringFragmentFromNode(org.w3c.dom.Node node,
boolean omitDeclaration,
java.lang.String encoding)
Takes the supplied node as the root of an xml document and converts it to a String representation.
|
static java.lang.String |
getXMLStringFragmentFromNode(org.w3c.dom.Node node,
boolean omitDeclaration,
java.lang.String encoding,
boolean collapseEmptyTags)
Takes the supplied node as the root of an xml document and converts it to a String representation.
|
static java.lang.String |
getXMLStringFragmentFromNode(org.w3c.dom.Node node,
java.lang.String encoding)
Takes the supplied node as the root of an xml document and converts it to a String representation.
|
static void |
removeAllAttributes(org.w3c.dom.Element element) |
static void |
removeAllChildNodes(org.w3c.dom.Node node)
Removes all child nodes from the context Node node.
|
static org.w3c.dom.Node |
removeEmptyElements(org.w3c.dom.Node node)
Deprecated.
|
static org.w3c.dom.Document |
removeEmptyNodes(org.w3c.dom.Node node) |
static org.w3c.dom.NodeList |
selectNodeList(org.w3c.dom.Node node,
java.lang.String expression) |
static java.lang.String |
selectNodeText(org.w3c.dom.Node node,
java.lang.String expression) |
static org.w3c.dom.Node |
selectSingleNode(org.w3c.dom.Node node,
java.lang.String expression) |
public static org.w3c.dom.Document getDocumentFromString(java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
xml
- to be parsedjavax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public static org.w3c.dom.Document createDocumentInstance() throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.Document createNamespacelessDocumentInstance() throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.Document getNamespacelessDocumentFromDocument(org.w3c.dom.Document dom) throws javax.xml.transform.TransformerException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
javax.xml.transform.TransformerException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
public static org.w3c.dom.Document getNamespacelessDocumentFromString(java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public static java.lang.String getNodeText(org.w3c.dom.Node node)
node
- to extract text from.public static java.lang.String getXMLStringFragmentFromNode(org.w3c.dom.Node node) throws javax.xml.transform.TransformerException
node
- to convert to a Stringjavax.xml.transform.TransformerException
public static java.lang.String getXMLStringFragmentFromNode(org.w3c.dom.Node node, java.lang.String encoding) throws javax.xml.transform.TransformerException
node
- to convert to a Stringencoding
- Target encoding of output XMLjavax.xml.transform.TransformerException
public static java.lang.String getXMLStringFragmentFromNode(org.w3c.dom.Node node, boolean omitDeclaration) throws javax.xml.transform.TransformerException
node
- to convert to a StringomitDeclaration
- set to false to include the <? xml ?> declarationjavax.xml.transform.TransformerException
public static java.lang.String getXMLStringFragmentFromNode(org.w3c.dom.Node node, boolean omitDeclaration, java.lang.String encoding) throws javax.xml.transform.TransformerException
node
- to convert to a StringomitDeclaration
- set to false to include the <? xml ?> declarationencoding
- Target encoding of output XMLjavax.xml.transform.TransformerException
public static java.lang.String getXMLStringFragmentFromNode(org.w3c.dom.Node node, boolean omitDeclaration, boolean collapseEmptyTags) throws javax.xml.transform.TransformerException
node
- to convert to a StringomitDeclaration
- set to false to include the <? xml ?> declarationcollapseEmptyTags
- set to false to use the long form of xml tags (ie. <a></a>)javax.xml.transform.TransformerException
public static java.lang.String getXMLStringFragmentFromNode(org.w3c.dom.Node node, boolean omitDeclaration, java.lang.String encoding, boolean collapseEmptyTags) throws javax.xml.transform.TransformerException
node
- to convert to a StringomitDeclaration
- set to false to include the <? xml ?> declarationencoding
- Target encoding of output XMLcollapseEmptyTags
- set to false to use the long form of xml tags (ie. <a></a>)javax.xml.transform.TransformerException
public static org.w3c.dom.Document removeEmptyNodes(org.w3c.dom.Node node) throws java.io.IOException, javax.xml.transform.TransformerException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
java.io.IOException
javax.xml.transform.TransformerException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.Node removeEmptyElements(org.w3c.dom.Node node) throws javax.xml.xpath.XPathExpressionException
node
- to remove all empty elements fromjavax.xml.xpath.XPathExpressionException
public static org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node node, java.lang.String expression) throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionException
public static java.lang.String selectNodeText(org.w3c.dom.Node node, java.lang.String expression) throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionException
public static org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node node, java.lang.String expression) throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionException
public static java.lang.String formatXMLStringForDisplay(java.lang.String xml)
xml
- to format for displaypublic static java.lang.String formatXMLStringForDisplay(java.lang.String xml, boolean omitDeclaration)
xml
- to format for displaypublic static void removeAllChildNodes(org.w3c.dom.Node node)
node
- to remove all children frompublic static void removeAllAttributes(org.w3c.dom.Element element)
public static org.xml.sax.InputSource createUTF8InputSource(java.lang.String xml) throws java.io.UnsupportedEncodingException
xml
- java.io.UnsupportedEncodingException
public static org.xml.sax.InputSource createUTF8InputSource(org.w3c.dom.Node node) throws java.io.UnsupportedEncodingException, javax.xml.transform.TransformerException
node
- java.io.UnsupportedEncodingException
javax.xml.transform.TransformerException
public static org.w3c.dom.Node alphabetiseChildNodes(org.w3c.dom.Node root) throws javax.xml.xpath.XPathExpressionException
root
- javax.xml.xpath.XPathExpressionException
Copyright © 2004-2014 The YAWL Foundation.