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.
24 public interface XPathSchemaContext {
26 * Compile an XPath expression for execution on {@link XPathDocument}s produced by this context.
29 * The user must provide a prefix-to-mapping {@link Converter}, which will be used to convert any prefixes found
30 * in the XPath expression being compiled in the resulting context.
32 * @param schemaPath Schema path of the node at which this expression is expected to be evaluated
33 * @param prefixes Prefix-to-namespace converter
34 * @param xpath XPath expression to compile
35 * @return A compiled XPath expression
36 * @throws XPathExpressionException if the provided expression is invalid, either syntactically or by referencing
37 * namespaces unknown to this schema context.
39 @NonNull XPathExpression compileExpression(@NonNull SchemaPath schemaPath,
40 @NonNull Converter<String, QNameModule> prefixes, @NonNull String xpath) throws XPathExpressionException;
43 * Create a new document context.
45 * @param documentRoot Root node of the document
46 * @return A new {@link XPathDocument} on which queries may be executed.
47 * @throws IllegalArgumentException if the document root is not known to this schema context.
49 @NonNull XPathDocument createDocument(@NonNull NormalizedNode<?, ?> documentRoot);