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 com.google.common.base.Converter;
12 import javax.xml.xpath.XPathExpressionException;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.yang.common.QNameModule;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 * A schema-informed XPath context. It supports creation of {@link XPathDocument}s, which are bound to
20 * a particular root node.
23 public interface XPathSchemaContext {
25 * Compile an XPath expression for execution on {@link XPathDocument}s produced by this context.
28 * The user must provide a prefix-to-mapping {@link Converter}, which will be used to convert any prefixes found
29 * in the XPath expression being compiled in the resulting context.
31 * @param schemaPath Schema path of the node at which this expression is expected to be evaluated
32 * @param prefixes Prefix-to-namespace converter
33 * @param xpath XPath expression to compile
34 * @return A compiled XPath expression
35 * @throws XPathExpressionException if the provided expression is invalid, either syntactically or by referencing
36 * namespaces unknown to this schema context.
38 @NonNull XPathExpression compileExpression(@NonNull SchemaPath schemaPath,
39 @NonNull Converter<String, QNameModule> prefixes, @NonNull String xpath) throws XPathExpressionException;
42 * Create a new document context.
44 * @param documentRoot Root node of the document
45 * @return A new {@link XPathDocument} on which queries may be executed.
46 * @throws IllegalArgumentException if the document root is not known to this schema context.
48 @NonNull XPathDocument createDocument(@NonNull NormalizedNode<?, ?> documentRoot);