public final class DomUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Element |
addElement(Document document,
Element parentDom,
String namespace,
String name)
This method creates and adds a new XML
Element |
static Element |
addTextElement(Document document,
Element parentDom,
String namespace,
String name,
String value)
This method creates and adds a new XML
Element with text value |
static Document |
buildDOM()
Creates the new empty Document.
|
static Document |
buildDOM(byte[] bytes)
This method returns the
Document created based on byte array. |
static Document |
buildDOM(DSSDocument dssDocument)
This method returns the
Document created based on the DSSDocument. |
static Document |
buildDOM(InputStream inputStream)
This method returns the
Document created based on the XML
inputStream. |
static Document |
buildDOM(String xmlString)
This method returns the
Document created based on the XML string. |
static DSSDocument |
createDssDocumentFromDomDocument(Document document,
String name)
This method creates a new InMemoryDocument with the
Document content and the given name |
static XMLGregorianCalendar |
createXMLGregorianCalendar(Date date)
Converts a given
Date to a new XMLGregorianCalendar. |
static List<String> |
getChildrenNames(Node xmlNode,
String xPathString)
This method returns the list of children's names for a given
Node. |
static Map<String,String> |
getCurrentNamespaces()
This method returns stored namespace definitions
|
static Date |
getDate(String text)
This method allows to convert the given text (XML representation of a date) to the
Date. |
static Element |
getElement(Node xmlNode,
String xPathString)
Returns the Element corresponding to the XPath query.
|
static String |
getId(String uri) |
static Node |
getNode(Node xmlNode,
String xPathString)
Returns the Node corresponding to the XPath query.
|
static NodeList |
getNodeList(Node xmlNode,
String xPathString)
Returns the NodeList corresponding to the XPath query.
|
static Transformer |
getSecureTransformer()
This method returns a new instance of Transformer with secured features enabled
|
static TransformerFactory |
getSecureTransformerFactory()
This method returns a new instance of TransformerFactory with secured features enabled
|
static String |
getValue(Node xmlNode,
String xPathString)
Returns the String value of the corresponding to the XPath query.
|
static String |
getXPathByIdAttribute(String uri) |
static boolean |
isDOM(byte[] bytes)
This method returns true if the binaries contains a
Document |
static boolean |
isNotEmpty(Node xmlNode,
String xPathString)
Returns true if the xpath query contains something
|
static boolean |
registerNamespace(String prefix,
String namespace)
This method allows to register a namespace and associated prefix.
|
static void |
setTextNode(Document document,
Element parentDom,
String text)
This method sets a text node to the given DOM element.
|
static void |
writeDocumentTo(Document dom,
OutputStream os)
This method writes the
Document content to an
outputStream |
static String |
xmlToString(Node node)
This method allows to convert an XML
Node to a String. |
public static boolean registerNamespace(String prefix, String namespace)
prefix - namespace prefixnamespace - namespacepublic static TransformerFactory getSecureTransformerFactory()
public static Transformer getSecureTransformer()
public static Document buildDOM()
public static Document buildDOM(String xmlString)
Document created based on the XML string.xmlString - The string representing the dssDocument to be created.Document with the xmlString contentpublic static Document buildDOM(byte[] bytes)
Document created based on byte array.bytes - The bytes array representing the dssDocument to be created.Document with the bytes contentpublic static Document buildDOM(DSSDocument dssDocument)
Document created based on the DSSDocument.dssDocument - The DSS representation of the document from which the dssDocument is created.Document from DSSDocumentpublic static boolean isDOM(byte[] bytes)
Documentbytes - the binaries to be testedpublic static Document buildDOM(InputStream inputStream)
Document created based on the XML
inputStream.inputStream - The inputStream stream representing the dssDocument to be
created.Document from InputStream @public static Element addElement(Document document, Element parentDom, String namespace, String name)
Elementdocument - root documentparentDom - parent nodenamespace - namespacename - element namepublic static String getValue(Node xmlNode, String xPathString)
xmlNode - The node where the search should be performed.xPathString - XPath query stringpublic static NodeList getNodeList(Node xmlNode, String xPathString)
xmlNode - The node where the search should be performed.xPathString - XPath query stringpublic static Node getNode(Node xmlNode, String xPathString)
xmlNode - The node where the search should be performed.xPathString - XPath query stringpublic static Element getElement(Node xmlNode, String xPathString)
xmlNode - The node where the search should be performed.xPathString - XPath query stringpublic static boolean isNotEmpty(Node xmlNode, String xPathString)
xmlNode - the current nodexPathString - the expected child nodepublic static Element addTextElement(Document document, Element parentDom, String namespace, String name, String value)
Element with text valuedocument - root documentparentDom - parent nodenamespace - namespacename - element namevalue - element text node valuepublic static void setTextNode(Document document, Element parentDom, String text)
document - root documentparentDom - parent nodetext - text to be addedpublic static XMLGregorianCalendar createXMLGregorianCalendar(Date date)
Date to a new XMLGregorianCalendar.date - the date to be convertedXMLGregorianCalendar or nullpublic static Date getDate(String text)
Date.text - the text representing the XML dateDate converted or nullpublic static List<String> getChildrenNames(Node xmlNode, String xPathString)
Node.xmlNode - The node where the search should be performed.xPathString - XPath query stringList of children's namespublic static void writeDocumentTo(Document dom, OutputStream os)
Document content to an
outputStreamdom - the Document to be writedos - the OutputStream @ if any error occurredpublic static DSSDocument createDssDocumentFromDomDocument(Document document, String name)
Document content and the given namedocument - the Document to storename - the ouput filenamepublic static String xmlToString(Node node)
Node to a String.node - Node to be convertedString representation of the nodepublic static Map<String,String> getCurrentNamespaces()
Copyright © 2019. All rights reserved.