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.jaxen;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.Converter;
13 import javax.annotation.Nonnull;
14 import javax.xml.xpath.XPathExpressionException;
15 import org.jaxen.JaxenException;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathDocument;
19 import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathExpression;
20 import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathSchemaContext;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24 final class JaxenSchemaContext implements XPathSchemaContext {
25 // Will be needed for compileExpression()
26 private final SchemaContext context;
28 JaxenSchemaContext(final SchemaContext context) {
29 this.context = requireNonNull(context);
34 public XPathExpression compileExpression(@Nonnull final SchemaPath schemaPath,
35 final Converter<String, QNameModule> prefixes, @Nonnull final String xpath)
36 throws XPathExpressionException {
38 return JaxenXPath.create(prefixes, schemaPath, xpath);
39 } catch (JaxenException e) {
40 throw new XPathExpressionException(e);
46 public XPathDocument createDocument(@Nonnull final NormalizedNode<?, ?> documentRoot) {
47 return new JaxenDocument(this, documentRoot);
51 SchemaContext getSchemaContext() {