2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.xpath.api;
10 import com.google.common.annotations.Beta;
11 import javax.xml.xpath.XPathExpressionException;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.common.QName;
16 public interface YangXPathExpression extends Immutable {
18 YangExpr getRootExpr();
21 * Attempt to interpret a {@link YangLiteralExpr} referenced by this expression as a {@link QName}. This method
22 * is required to perform late value binding of the expression when the literal needs to be interpreted as
23 * a reference to an {@code identity}.
26 * The syntax of expr is required to conform to
27 * <a href="https://www.w3.org/TR/REC-xml-names/#NT-QName">XML QName format</a>, as further restricted by
28 * <a href="https://tools.ietf.org/html/rfc7950#section-9.10.3">YANG {@code identityref} Lexical Representation</a>.
31 * Unfortunately we do not know when a literal will need to be interpreted in this way, as that can only be known
34 * @param expr Literal to be reinterpreted
35 * @return QName representation of the literal
36 * @throws XPathExpressionException when the literal cannot be interpreted as a QName
38 QName interpretAsQName(YangLiteralExpr expr) throws XPathExpressionException;
40 // API design: this really should be YangInstanceIdentifier without AugmentationIdentifier. Implementations are
41 // strongly encouraged to validate it as such.
42 YangLocationPath interpretAsInstanceIdentifier(YangLiteralExpr expr) throws XPathExpressionException;