Here you can find the source of getSearchHandlerNode(final File solrconfig)
Parameter | Description |
---|---|
solrconfig | the solrconfig.xml File |
Parameter | Description |
---|---|
ParserConfigurationException | an exception |
SAXException | an exception |
IOException | an exception |
XPathExpressionException | an exception |
public static Node getSearchHandlerNode(final File solrconfig) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.SAXException; public class Main { /**/*from ww w. ja v a 2 s .c o m*/ * Get the searchHandler Node from the solrconfig.xml file * * @param solrconfig * the solrconfig.xml File * * @return searchHandler XML Node or null if not found * * @throws ParserConfigurationException * @throws SAXException * @throws IOException * @throws XPathExpressionException */ public static Node getSearchHandlerNode(final File solrconfig) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); final Document docSchem = dBuilder.parse(solrconfig); final XPathFactory xPathfactory = XPathFactory.newInstance(); final XPath xpath = xPathfactory.newXPath(); final XPathExpression expr = xpath .compile("//requestHandler[@class=\"solr.SearchHandler\" and @name=\"/select\"]"); final Node requestHandler = (Node) expr.evaluate(docSchem, XPathConstants.NODE); return requestHandler; } }