2 * Copyright 2005-2011 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.xml;
18 import javax.xml.namespace.NamespaceContext;
19 import javax.xml.xpath.XPath;
20 import javax.xml.xpath.XPathFactory;
23 * Represents a namespace context and is a factory for creating xpath expressions.
24 * @author Erik Brakkee
26 public class XPathContext {
30 * Constructs the context.
31 * @param aContext Namespaces.
33 public XPathContext(NamespaceContext aContext) {
34 xpath = XPathFactory.newInstance().newXPath();
35 xpath.setNamespaceContext(aContext);
39 * Creation of the XPath context for use with static imports.
40 * @param aContext Namespace context
41 * @return XPath context.
43 public static XPathContext xpathcontext(NamespaceContext aContext) {
44 return new XPathContext(aContext);
48 * Creates the expression.
49 * @param aExpression XPath expression.
50 * @return Xpath expression.
51 * @throws XMLException
53 public XPathExpression createExpression(String aExpression) throws XMLException {
54 return new XPathExpression(xpath, aExpression);
58 * To get access to the lower level API.
59 * @return Lower level API.
61 public XPath getXpath() {