public class XmlUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
XmlUtils.TransformerRuntimeException
Runtime version of
TransformerException |
| Constructor and Description |
|---|
XmlUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkRootElement(Document document,
String expectedRootElementName)
Check that the name of root element of the given
document matches the given expectedRootElementName |
static String |
flush(Document in)
Serialise the given
Document into a String. |
static void |
flush(Document in,
OutputStream out)
Serialise the given
Document in the given OutputStream. |
static void |
flush(Document in,
OutputStream out,
Map<String,String> outputProperties)
Serialise the given
Document in the given OutputStream. |
static void |
flush(Document in,
Result out,
Map<String,String> outputProperties)
|
static void |
flush(Document in,
Writer out)
|
static void |
flush(Document in,
Writer out,
Map<String,String> outputProperties)
|
static String |
flush(Node in)
Serialise the given
Document into a String. |
static void |
flush(Node in,
OutputStream out)
Serialise the given
Node in the given OutputStream. |
static void |
flush(Node in,
OutputStream out,
Map<String,String> outputProperties)
Serialise the given
Node in the given OutputStream. |
static void |
flush(Node in,
Result out,
Map<String,String> outputProperties)
|
static void |
flush(Node in,
Writer out)
|
static void |
flush(Node in,
Writer out,
Map<String,String> outputProperties)
|
static Element |
getUniqueElement(Document document,
String xpathExpression)
Returns the unique XML element matching the given
xpathExpression |
static Element |
getUniqueElement(Element element,
String xpathExpression)
Returns the unique XML element matching the given
xpathExpression |
static Element |
getUniqueElement(Node node,
String xpathExpression)
Returns the unique XML element matching the given
xpathExpression |
static void |
insertSiblingAfter(Element newElement,
Element sibling)
Insert the given
newElement just next to the given sibling, after it. |
static Document |
loadXmlDocumentFromFile(File file)
Load the given
file as an XML document. |
static Document |
loadXmlDocumentFromPath(Path path)
Load the given
path as an XML document. |
static Document |
loadXmlDocumentFromStream(InputStream in)
Load the given
InputStream as an XML document. |
static void |
setElementTextContent(Element element,
String xpath,
String value) |
@Nonnull public static Element getUniqueElement(@Nonnull Document document, @Nonnull String xpathExpression) throws RuntimeException
xpathExpressiondocument - xpathExpression - xpath expression to find the elementRuntimeException - 0 or more than 1 matching element found@Nonnull public static Element getUniqueElement(@Nonnull Element element, @Nonnull String xpathExpression)
xpathExpressionelement - xpathExpression - xpath expression to find the elementRuntimeException - 0 or more than 1 matching element found@Nonnull public static Element getUniqueElement(@Nonnull Node node, @Nonnull String xpathExpression)
xpathExpressionnode - xpathExpression - xpath expression to find the nodeRuntimeException - 0 or more than 1 matching element found@Nonnull public static Document loadXmlDocumentFromFile(@Nonnull File file) throws ParserConfigurationException, IOException, SAXException
file as an XML document.file - ParserConfigurationExceptionIOExceptionSAXException@Nonnull public static Document loadXmlDocumentFromPath(@Nonnull Path path) throws ParserConfigurationException, IOException, SAXException
path as an XML document.path - ParserConfigurationExceptionIOExceptionSAXException@Nonnull public static Document loadXmlDocumentFromStream(@Nonnull InputStream in) throws ParserConfigurationException, IOException, SAXException
InputStream as an XML document.in - ParserConfigurationExceptionIOExceptionSAXExceptionpublic static void checkRootElement(@Nonnull Document document, @Nullable String expectedRootElementName)
document matches the given expectedRootElementNamedocument - expectedRootElementName - @Nonnull public static String flush(@Nonnull Document in) throws XmlUtils.TransformerRuntimeException
Document into a String.in - XmlUtils.TransformerRuntimeException@Nonnull public static String flush(@Nonnull Node in) throws XmlUtils.TransformerRuntimeException
Document into a String.in - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Document in, @Nonnull OutputStream out) throws XmlUtils.TransformerRuntimeException
Document in the given OutputStream.in - out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Node in, @Nonnull OutputStream out) throws XmlUtils.TransformerRuntimeException
Node in the given OutputStream.in - out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Document in, @Nonnull Writer out) throws XmlUtils.TransformerRuntimeException
in - out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Node in, @Nonnull Writer out) throws XmlUtils.TransformerRuntimeException
in - out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Document in, @Nonnull OutputStream out, @Nullable Map<String,String> outputProperties) throws XmlUtils.TransformerRuntimeException
Document in the given OutputStream.in - outputProperties - see Transformer.setOutputProperty(String, String)out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Node in, @Nonnull OutputStream out, @Nullable Map<String,String> outputProperties) throws XmlUtils.TransformerRuntimeException
Node in the given OutputStream.in - outputProperties - see Transformer.setOutputProperty(String, String)out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Document in, @Nonnull Writer out, @Nullable Map<String,String> outputProperties) throws XmlUtils.TransformerRuntimeException
in - outputProperties - see Transformer.setOutputProperty(String, String)out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Node in, @Nonnull Writer out, @Nullable Map<String,String> outputProperties) throws XmlUtils.TransformerRuntimeException
in - outputProperties - see Transformer.setOutputProperty(String, String)out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Document in, @Nonnull Result out, @Nullable Map<String,String> outputProperties) throws XmlUtils.TransformerRuntimeException
in - outputProperties - see Transformer.setOutputProperty(String, String)out - XmlUtils.TransformerRuntimeExceptionpublic static void flush(@Nonnull Node in, @Nonnull Result out, @Nullable Map<String,String> outputProperties) throws XmlUtils.TransformerRuntimeException
in - outputProperties - see Transformer.setOutputProperty(String, String)out - XmlUtils.TransformerRuntimeExceptionpublic static void insertSiblingAfter(@Nonnull Element newElement, @Nonnull Element sibling)
newElement just next to the given sibling, after it.newElement - sibling - Copyright © 2013-2014. All Rights Reserved.