2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf.util.xml;
11 import javax.xml.xpath.XPath;
12 import javax.xml.xpath.XPathExpression;
13 import javax.xml.xpath.XPathExpressionException;
14 import javax.xml.xpath.XPathFactory;
16 public final class XMLNetconfUtil {
18 private XMLNetconfUtil() {}
20 public static XPathExpression compileXPath(String xPath) {
21 final XPathFactory xPathfactory = XPathFactory.newInstance();
22 final XPath xpath = xPathfactory.newXPath();
23 xpath.setNamespaceContext(new HardcodedNamespaceResolver("netconf",
24 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
26 return xpath.compile(xPath);
27 } catch (final XPathExpressionException e) {
28 throw new IllegalStateException("Error while compiling xpath expression " + xPath, e);