Jaxen binding should use DataSchemaContextTree
[yangtools.git] / yang / yang-data-jaxen / src / main / java / org / opendaylight / yangtools / yang / data / jaxen / NormalizedNodeContextSupport.java
index 441e7d672dbb28ed0c08f1edae89443d0147e87a..67c7376b54cc1ebcf044ff54be0520f6a6fa88f1 100644 (file)
@@ -27,7 +27,7 @@ final class NormalizedNodeContextSupport extends ContextSupport {
     private NormalizedNodeContextSupport(final ConverterNamespaceContext context,
             final NormalizedNodeNavigator navigator) {
         super(context, YangFunctionContext.getInstance(), new SimpleVariableContext(), navigator);
-        this.root = new NormalizedNodeContext(this, navigator.getRootNode(), null);
+        this.root = NormalizedNodeContext.forRoot(this);
     }
 
     static NormalizedNodeContextSupport create(final JaxenDocument document,
@@ -43,18 +43,17 @@ final class NormalizedNodeContextSupport extends ContextSupport {
         for (PathArgument arg : path.getPathArguments()) {
             final Optional<NormalizedNode<?, ?>> node = NormalizedNodes.getDirectChild(result.getNode(), arg);
             checkArgument(node.isPresent(), "Node %s has no child %s", result.getNode(), arg);
-            result = new NormalizedNodeContext(this, node.get(), result);
+            result = result.apply(node.get());
         }
-
         return result;
     }
 
-    SchemaContext getSchemaContext() {
-        return getNavigator().getSchemaContext();
-    }
-
     @Override
     public NormalizedNodeNavigator getNavigator() {
         return (NormalizedNodeNavigator) super.getNavigator();
     }
+
+    SchemaContext getSchemaContext() {
+        return getNavigator().getDocument().getSchemaContext();
+    }
 }