Document d = null;
try {
d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(fs.open(new Path(qfile)));
} catch (SAXException e) {
throw new ConfigurationException(e.getMessage());
} catch (IOException e) {
throw new ConfigurationException(e.getMessage());
} catch (ParserConfigurationException e) {
throw new ConfigurationException(e.getMessage());
}
Map<String, String> queries = Maps.newLinkedHashMap();
NodeList queryNodes = d.getElementsByTagName("query");
System.out.println("Parsing "+queryNodes.getLength()+" nodes...");
for (int i = 0; i < queryNodes.getLength(); i++) {
// Get query XML node.
Node node = queryNodes.item(i);
// Get query id.
String qid = XMLTools.getAttributeValueOrThrowException(node, "id",
"Must specify a query id attribute for every query!");
// Get query text.
String queryText = node.getTextContent();
// Add query to internal map.
if (queries.get(qid) != null) {
throw new ConfigurationException(
"Duplicate query ids not allowed! Already parsed query with id=" + qid);
}
queries.put(qid, queryText);
}