2 * Copyright (c) 2015 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
8 package org.opendaylight.yangtools.yang.data.api.schema.xpath;
10 import com.google.common.annotations.Beta;
11 import javax.annotation.Nonnull;
12 import javax.xml.xpath.XPathExpressionException;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17 * A schema-informed XPath context. It supports creation of {@link XPathDocument}s, which are bound to
18 * a particular root node.
21 public interface XPathSchemaContext {
23 * Compile an XPath expression for execution on {@link XPathDocument}s produced by this context.
25 * @param xpath XPath expression to compile
26 * @param schemaPath Schema path of the node at which this expression is expected to be evaluated
27 * @return A compiled XPath expression
28 * @throws XPathExpressionException if the provided expression is invalid, either syntactically or by referencing
29 * namespaces unknown to this schema context.
31 @Nonnull XPathExpression compileExpression(@Nonnull String xpath, @Nonnull SchemaPath schemaPath)
32 throws XPathExpressionException;
35 * Create a new document context.
37 * @param documentRoot Root node of the document
38 * @return A new {@link XPathDocument} on which queries may be executed.
39 * @throws IllegalArgumentException if the document root is not known to this schema context.
41 @Nonnull XPathDocument createDocument(@Nonnull NormalizedNode<?, ?> documentRoot);