|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ow2.dragon.util.XMLUtil
public final class XMLUtil
Contains utilities methods for XML operations.
| Method Summary | |
|---|---|
static int |
compareXML(java.io.InputStream xml1,
java.io.InputStream xml2)
|
static org.w3c.dom.Node |
createAttribute(org.w3c.dom.Document document,
java.lang.String att,
java.lang.String value)
Create an attribute node with the specified value |
static org.w3c.dom.Document |
createDocument()
Get a new document |
static org.w3c.dom.Document |
createDocument(org.xml.sax.InputSource is)
Get a new document from an InputSource |
static org.w3c.dom.Document |
createDocument(java.io.InputStream is)
Get a new document from an InputStream |
static org.w3c.dom.Document |
createDocumentFromString(java.lang.String xml)
Create a document from a String |
static org.w3c.dom.Node |
createNode(org.w3c.dom.Document document,
java.lang.String nodeName,
java.lang.String... attVal)
Create a node with the specified name, attributes and values. attVal is a suite : att1,val1,att2,val2,... |
static java.lang.String |
createStringFromDOMDocument(org.w3c.dom.Node document)
Create a String result from a DOM document |
static java.lang.String |
createStringFromDOMNode(org.w3c.dom.Node node)
Create a String result from a DOM Node |
static java.lang.String |
createStringFromDOMNode(org.w3c.dom.Node node,
boolean omitDeclaration)
Create a String result from a DOM Node |
static java.lang.String |
createStringFromDOMNodeList(org.w3c.dom.NodeList list)
Create a String from a Node list |
static javax.xml.namespace.QName |
extractRequiredXmlAttributeQName(org.w3c.dom.Node node,
java.lang.String attrName)
|
static javax.xml.namespace.QName |
extractXmlAttributeQName(org.w3c.dom.Node node,
java.lang.String attrName)
Return the QName extracted from the targeted attribute of the given Node |
static java.lang.String |
extractXmlEncoding(java.lang.String msg)
Extract the xml header charset encoding from the given xml String |
static org.w3c.dom.Node |
findChild(org.w3c.dom.Node node,
java.lang.String nodeName,
boolean recursive)
Deprecated. Use findChild(Node, String, String, boolean) with a
namespace set to null. |
static org.w3c.dom.Node |
findChild(org.w3c.dom.Node node,
java.lang.String nodeName,
java.lang.String namespaceURI,
boolean recursive)
Search for a child with the given nodeName. |
static java.lang.String |
getAttributeValue(org.w3c.dom.Node n,
java.lang.String attName)
Return the value of the attribute in the node |
static org.w3c.dom.Node |
getFirstChild(org.w3c.dom.Node node)
Return the first child of a node, regardless text node and CDATA sections |
static org.w3c.dom.Node |
getNextSibling(org.w3c.dom.Node node)
Return the next sibling of a node, regardless text node and CDATA sections |
static org.w3c.dom.Node |
getNode(org.w3c.dom.Document document,
java.lang.String elementName)
|
static java.util.List<org.w3c.dom.Node> |
getNodeChildren(org.w3c.dom.Node node)
A List of Node that contains all children of this node; nodes must be of type Node.ELEMENT_NODE to be returned. |
static org.w3c.dom.Node |
getNodeWithAttribute(org.w3c.dom.Document document,
java.lang.String elementName,
java.lang.String attributeName,
java.lang.String attributeValue)
|
static java.lang.String |
getRequiredAttributeValue(org.w3c.dom.Node n,
java.lang.String attName)
Return the value of the attribute in the node. |
static java.lang.String |
getTextContent(org.w3c.dom.Node node)
Return the text element of a node, even if it is contained in a CDATA section |
static java.util.List<java.lang.String> |
getTextContents(org.w3c.dom.NodeList list)
Return an array of String representing each Text element of the nodes which are in the list. |
static java.lang.String |
getXMLSHA1Sign(java.io.InputStream inputStream,
boolean ommitComments)
|
static org.w3c.dom.Document |
loadDocument(java.io.InputStream inputStream)
Load a document from an input stream. |
static java.lang.String |
parseToString(org.w3c.dom.Node node)
Transform an XML Node into a String |
static void |
writeDocument(org.w3c.dom.Document document,
java.io.OutputStream outputStream)
Write a document to an output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static org.w3c.dom.Node createAttribute(org.w3c.dom.Document document,
java.lang.String att,
java.lang.String value)
document - XML documentatt - attribute namevalue - attribute value
public static org.w3c.dom.Node createNode(org.w3c.dom.Document document,
java.lang.String nodeName,
java.lang.String... attVal)
document - xlm documentnodeName - node nameattVal - attribute values
@Deprecated
public static org.w3c.dom.Node findChild(org.w3c.dom.Node node,
java.lang.String nodeName,
boolean recursive)
findChild(Node, String, String, boolean) with a
namespace set to null.
node - parent nodenodeName - node namerecursive - boolean to know if we got through the xml tree
public static org.w3c.dom.Node findChild(org.w3c.dom.Node node,
java.lang.String nodeName,
java.lang.String namespaceURI,
boolean recursive)
node - parent nodenamespaceURI - The namespaceURI of the node. if null, the namespace is
ignorednodeName - node namerecursive - boolean to know if we got through the xml tree
public static java.lang.String parseToString(org.w3c.dom.Node node)
throws javax.xml.transform.TransformerException
Node into a String
node - the XML Node to parse
javax.xml.transform.TransformerException - if errors occured during transformation
public static java.lang.String getAttributeValue(org.w3c.dom.Node n,
java.lang.String attName)
n - the nodeattName - the name of the attribute
public static java.lang.String getRequiredAttributeValue(org.w3c.dom.Node n,
java.lang.String attName)
n - the nodeattName - the name of the attribute, must be non null
java.lang.NullPointerException - if attribute not found in the nodepublic static org.w3c.dom.Node getFirstChild(org.w3c.dom.Node node)
node -
public static org.w3c.dom.Node getNextSibling(org.w3c.dom.Node node)
node -
null if node
is null or no sibling node exists.public static java.lang.String getTextContent(org.w3c.dom.Node node)
node -
public static java.lang.String createStringFromDOMDocument(org.w3c.dom.Node document)
throws javax.xml.transform.TransformerException
document - the DOM Document. Must not be null
javax.xml.transform.TransformerException
public static java.lang.String createStringFromDOMNode(org.w3c.dom.Node node)
throws javax.xml.transform.TransformerException
node - the DOM Node. Must not be null
javax.xml.transform.TransformerException
public static java.lang.String createStringFromDOMNodeList(org.w3c.dom.NodeList list)
throws javax.xml.transform.TransformerException
String from a Node list
list -
javax.xml.transform.TransformerException
public static java.lang.String createStringFromDOMNode(org.w3c.dom.Node node,
boolean omitDeclaration)
throws javax.xml.transform.TransformerException
node - the DOM Node. Must not be null
javax.xml.transform.TransformerExceptionpublic static org.w3c.dom.Document createDocumentFromString(java.lang.String xml)
xml - an xml string
Document representing the document, null if an error
occuredpublic static java.util.List<java.lang.String> getTextContents(org.w3c.dom.NodeList list)
list -
public static javax.xml.namespace.QName extractXmlAttributeQName(org.w3c.dom.Node node,
java.lang.String attrName)
Node
node - the node from which attribute must be extractedattrName - name of the targeted attribute
QName value of the targeted Node attribute,
null if not found
java.lang.IllegalArgumentException - If the String does not conform to one of the following
pattern : "localPart", "{ns}localPart" or "ns:localPart".public static java.lang.String extractXmlEncoding(java.lang.String msg)
msg - the xml String
public static javax.xml.namespace.QName extractRequiredXmlAttributeQName(org.w3c.dom.Node node,
java.lang.String attrName)
node - attrName -
public static java.util.List<org.w3c.dom.Node> getNodeChildren(org.w3c.dom.Node node)
node - the node from which children will be extracted
public static org.w3c.dom.Node getNode(org.w3c.dom.Document document,
java.lang.String elementName)
document - elementName -
public static org.w3c.dom.Node getNodeWithAttribute(org.w3c.dom.Document document,
java.lang.String elementName,
java.lang.String attributeName,
java.lang.String attributeValue)
document - elementName - attributeName - attributeValue -
public static void writeDocument(org.w3c.dom.Document document,
java.io.OutputStream outputStream)
throws java.lang.Exception
document - outputFile -
java.lang.Exception
public static org.w3c.dom.Document loadDocument(java.io.InputStream inputStream)
throws java.io.IOException,
org.xml.sax.SAXException
inputStream -
java.io.IOException
org.xml.sax.SAXExceptionpublic static org.w3c.dom.Document createDocument()
public static org.w3c.dom.Document createDocument(java.io.InputStream is)
throws org.xml.sax.SAXException,
java.io.IOException
InputStream
java.io.IOException
org.xml.sax.SAXException
public static org.w3c.dom.Document createDocument(org.xml.sax.InputSource is)
throws org.xml.sax.SAXException,
java.io.IOException
InputSource
java.io.IOException
org.xml.sax.SAXException
public static java.lang.String getXMLSHA1Sign(java.io.InputStream inputStream,
boolean ommitComments)
throws java.lang.Exception
java.lang.Exception
public static int compareXML(java.io.InputStream xml1,
java.io.InputStream xml2)
throws java.lang.Exception
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||