import java.util.Map;
import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
File file = getXmlFilesPath().addTrailingSeparator().append(fileName).toFile();
if (file.exists()) {
try {
- /* Load the XML File */
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder;
- dBuilder = dbFactory.newDocumentBuilder();
- Document doc = dBuilder.parse(file);
- doc.getDocumentElement().normalize();
+ Document doc = getDocumentFromFile(file);
/* get State Providers modules */
NodeList stateproviderNodes = doc.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER);
return ids;
}
+ /**
+ * Load the XML File
+ *
+ * @param file
+ * The XML file
+ * @return The document representing the XML file
+ * @throws ParserConfigurationException
+ * if a DocumentBuilder cannot be created
+ * @throws SAXException
+ * If any parse errors occur.
+ * @throws IOException
+ * If any IO errors occur.
+ * @since 2.0
+ */
+ public static Document getDocumentFromFile(File file) throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ Document doc = dbFactory.newDocumentBuilder().parse(file);
+ doc.getDocumentElement().normalize();
+ return doc;
+ }
+
/**
* Get only the XML element children of an XML element.
*
}
try {
- /* Load the XML File */
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder;
-
- dBuilder = dbFactory.newDocumentBuilder();
- Document doc = dBuilder.parse(file);
- doc.getDocumentElement().normalize();
+ Document doc = getDocumentFromFile(file);
/* get the state providers and find the corresponding one */
NodeList nodes = doc.getElementsByTagName(elementType);