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