import java.io.File;
import java.io.IOException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlUtils;
import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.Activator;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/* Initialize the state provider module */
Document doc = null;
try {
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
- doc = dBuilder.parse(getFile());
- doc.getDocumentElement().normalize();
+ doc = XmlUtils.getDocumentFromFile(getFile());
} catch (ParserConfigurationException e) {
fail("Xml document parse exception");
} catch (SAXException e) {
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.FileLocator;
}
try {
- /* Load the XML File */
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
- Document doc = dBuilder.parse(xmlFile);
- doc.getDocumentElement().normalize();
+ Document doc = XmlUtils.getDocumentFromFile(xmlFile);
/* get State Providers modules */
NodeList stateproviderNodes = doc.getElementsByTagName(TmfXmlStrings.STATE_PROVIDER);
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);
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.jdt.annotation.NonNull;
}
try {
- /* Load the XML File */
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
- Document doc = dBuilder.parse(xmlFile);
- doc.getDocumentElement().normalize();
+ Document doc = XmlUtils.getDocumentFromFile(xmlFile);
/* get state provider views if the analysis has state systems */
if (module instanceof ITmfAnalysisModuleWithStateSystems) {