|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.soa.esb.dom.YADOMUtil
public class YADOMUtil
Yet another set of DOM utility methods.
PLEASE DO NOT USE THIS CLASS OUTSIDE THIS PACKAGE. It will be removed as soon as we find equivalent DOM support methods somewhere else, or find a more appropriate home for these.
Constructor Summary | |
---|---|
YADOMUtil()
|
Method Summary | |
---|---|
static org.w3c.dom.Element |
addElement(org.w3c.dom.Node parent,
java.lang.String elementName)
Add an Element node to the supplied parent name. |
static void |
copyChildNodes(org.w3c.dom.Node source,
org.w3c.dom.Node target)
Copy child node references from source to target. |
static java.util.List<org.w3c.dom.Node> |
copyNodeList(org.w3c.dom.NodeList nodeList)
Copy the nodes of a NodeList into the supplied list. |
static int |
countElementsBefore(org.w3c.dom.Node node,
java.lang.String tagName)
Count the DOM element nodes before the supplied node, having the specified tag name, not including the node itself. |
static org.w3c.dom.Document |
createDocument()
Create a new W3C Document. |
static java.lang.String |
getAttribute(org.w3c.dom.Element element,
java.lang.String name,
java.lang.String defaultVal)
|
static org.w3c.dom.Comment |
getCommentBefore(org.w3c.dom.Element element)
Get the comment node before the supplied element. |
static org.w3c.dom.Node |
getFirstChildByType(org.w3c.dom.Element element,
int nodeType)
|
static org.w3c.dom.Element |
getFirstChildElement(org.w3c.dom.Element element)
Get the first child element for the supplied element. |
static org.w3c.dom.Element |
getFirstChildElementByName(org.w3c.dom.Element element,
java.lang.String name)
Get the first child of the supplied element that matches a given tag name. |
static org.w3c.dom.Element |
getLastChildElement(org.w3c.dom.Element element)
Get the last child element for the supplied element. |
static java.lang.String |
getName(org.w3c.dom.Element element)
Get the name from the supplied element. |
static org.w3c.dom.Element |
getNextSiblingElement(org.w3c.dom.Node node)
|
static org.w3c.dom.Node |
getNode(org.w3c.dom.Node node,
java.lang.String xpath)
Get the W3C Node instance associated with the XPath selection supplied. |
static org.w3c.dom.NodeList |
getNodeList(org.w3c.dom.Node node,
java.lang.String xpath)
Get the W3C NodeList instance associated with the XPath selection supplied. |
static org.w3c.dom.Document |
parse(java.lang.String xml)
Parse the supplied XML String and return the associated W3C Document object. |
static org.w3c.dom.Document |
parseStream(java.io.InputStream stream,
boolean validate,
boolean expandEntityRefs)
Parse the XML stream and return the associated W3C Document object. |
static org.w3c.dom.Document |
parseStream(java.io.InputStream stream,
boolean validate,
boolean expandEntityRefs,
boolean namespaceAware)
Parse the XML stream and return the associated W3C Document object. |
static void |
removeEmptyAttributes(org.w3c.dom.Element element)
Remove all attributes having an empty value. |
static void |
serialize(org.w3c.dom.Node node,
java.io.File outdir,
java.lang.String fileName)
Serialize the supplied DOM node to the specified file in the specified output directory. |
static void |
serialize(org.w3c.dom.Node node,
java.io.OutputStream out)
|
static void |
serialize(org.w3c.dom.Node node,
javax.xml.transform.stream.StreamResult streamRes)
Serialize the supplied DOM node to the supplied DOM StreamResult instance. |
static void |
serialize(org.w3c.dom.Node node,
javax.xml.transform.stream.StreamResult streamRes,
boolean omitXmlDecl)
Serialize the supplied DOM node to the supplied DOM StreamResult instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public YADOMUtil()
Method Detail |
---|
public static org.w3c.dom.Document createDocument() throws ConfigurationException
ConfigurationException
public static org.w3c.dom.Document parse(java.lang.String xml) throws org.xml.sax.SAXException, java.io.IOException
xml
- XML String.
org.xml.sax.SAXException
java.io.IOException
public static org.w3c.dom.Document parseStream(java.io.InputStream stream, boolean validate, boolean expandEntityRefs) throws org.xml.sax.SAXException, java.io.IOException
stream
- The stream to be parsed.validate
- True if the document is to be validated, otherwise false.expandEntityRefs
- Expand entity References as per
DocumentBuilderFactory.setExpandEntityReferences(boolean)
.
org.xml.sax.SAXException
java.io.IOException
public static org.w3c.dom.Document parseStream(java.io.InputStream stream, boolean validate, boolean expandEntityRefs, boolean namespaceAware) throws org.xml.sax.SAXException, java.io.IOException
stream
- The stream to be parsed.validate
- True if the document is to be validated, otherwise false.expandEntityRefs
- Expand entity References as per
DocumentBuilderFactory.setExpandEntityReferences(boolean)
.namespaceAware
- True if the document parse is to be namespace aware,
otherwise false.
org.xml.sax.SAXException
java.io.IOException
public static java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String name, java.lang.String defaultVal)
public static org.w3c.dom.Element addElement(org.w3c.dom.Node parent, java.lang.String elementName)
parent
- The parent to to which the new Element node is to be added.elementName
- The name of the Element to be added.
public static void removeEmptyAttributes(org.w3c.dom.Element element)
element
- The element to be processed.public static void serialize(org.w3c.dom.Node node, java.io.File outdir, java.lang.String fileName) throws ConfigurationException
node
- The DOM node to be serialised.outdir
- The directory into which the file is to be serialised.fileName
- The name of the file.
ConfigurationException
- Unable to serialise the node.public static void serialize(org.w3c.dom.Node node, java.io.OutputStream out) throws ConfigurationException
ConfigurationException
public static void serialize(org.w3c.dom.Node node, javax.xml.transform.stream.StreamResult streamRes) throws ConfigurationException
node
- The DOM node to be serialised.streamRes
- The StreamResult into which the node is to be serialised.
ConfigurationException
- Unable to serialise the node.public static void serialize(org.w3c.dom.Node node, javax.xml.transform.stream.StreamResult streamRes, boolean omitXmlDecl) throws ConfigurationException
node
- The DOM node to be serialised.streamRes
- The StreamResult into which the node is to be serialised.omitXmlDecl
- Omit the XML declaration.
ConfigurationException
- Unable to serialise the node.public static int countElementsBefore(org.w3c.dom.Node node, java.lang.String tagName)
node
- Node whose element siblings are to be counted.tagName
- The tag name of the sibling elements to be counted.
public static java.util.List<org.w3c.dom.Node> copyNodeList(org.w3c.dom.NodeList nodeList)
nodeList
- Nodelist to copy.
public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Node node)
public static org.w3c.dom.Node getFirstChildByType(org.w3c.dom.Element element, int nodeType)
public static org.w3c.dom.NodeList getNodeList(org.w3c.dom.Node node, java.lang.String xpath)
node
- The document node to be searched.xpath
- The XPath String to be used in the selection.
public static org.w3c.dom.Node getNode(org.w3c.dom.Node node, java.lang.String xpath)
node
- The document node to be searched.xpath
- The XPath String to be used in the selection.
public static java.lang.String getName(org.w3c.dom.Element element)
localName
of the element
if set (namespaced element), otherwise the
element's tagName
is returned.
NOTE: Taken from Milyn Smooks.
element
- The element.
public static void copyChildNodes(org.w3c.dom.Node source, org.w3c.dom.Node target)
source
- Source Node.target
- Target Node.public static org.w3c.dom.Comment getCommentBefore(org.w3c.dom.Element element)
element
- The element.
public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element element)
element
- The element.
public static org.w3c.dom.Element getLastChildElement(org.w3c.dom.Element element)
element
- The element.
public static org.w3c.dom.Element getFirstChildElementByName(org.w3c.dom.Element element, java.lang.String name)
element
- The element.name
- The name of the child element to search for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |