Constructor and Description |
---|
XmlUtils() |
Modifier and Type | Method and Description |
---|---|
static org.dom4j.Document |
documentFromString(String xml)
Parses a given string to produce a
Document instance. |
static org.dom4j.Document |
getXmlDoc(File f)
Read and parse an XML-file, and return a Document object representing this object.
|
static org.dom4j.Document |
getXmlDoc(InputStream resourceAsStream)
Read and parse an XML stream, and return a Document object representing this object.
|
static void |
setNode(org.dom4j.Document doc,
String xpath,
String value)
Set a XmlNode defined by the given XPath to the given value.
|
static void |
setNodes(org.dom4j.Document doc,
String xpath,
String value)
Set a List of XmlNodes defined by the given XPath to the given value.
|
static void |
validateWithXSD(File xsdFile)
Validate that the settings xml files conforms to the XSD.
|
static void |
writeXmlToFile(org.dom4j.Document doc,
File f)
Write document tree to file.
|
public XmlUtils()
public static org.dom4j.Document getXmlDoc(File f) throws IOFailure
f
- a given xml fileIOFailure
- if unable to read the xml file or unable to parse the file as XMLpublic static org.dom4j.Document getXmlDoc(InputStream resourceAsStream)
resourceAsStream
- a given xml documentIOFailure
- if unable to read the xml document or unable to parse the document as XMLpublic static void setNode(org.dom4j.Document doc, String xpath, String value)
doc
- the Document, which is being modifiedxpath
- the given XPathvalue
- the given valueIOFailure
- If the given XPath was not found in the documentpublic static void setNodes(org.dom4j.Document doc, String xpath, String value)
doc
- the Document, which is being modifiedxpath
- the given XPathvalue
- the given valueIOFailure
- If the given XPath was not found in the documentpublic static void validateWithXSD(File xsdFile)
xsdFile
- Schema to check settings against.ArgumentNotValid
- if unable to validate the settings filesIOFailure
- If unable to read the settings files and/or the xsd file.public static void writeXmlToFile(org.dom4j.Document doc, File f) throws IOFailure
doc
- the document tree to save.f
- the file to write the document to.IOFailure
- On trouble writing XML file to disk.public static org.dom4j.Document documentFromString(String xml) throws org.dom4j.DocumentException
Document
instance.xml
- Some XML text.Document
parsed from the given xml.org.dom4j.DocumentException
- If unable to parse the given text as XML.Copyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.