BUG-1382: eliminate QName.getPrefix() from GeneratorImpl.xtend
[yangtools.git] / code-generator / maven-sal-api-gen-plugin / src / main / java / org / opendaylight / yangtools / yang / unified / doc / generator / GeneratorImpl.xtend
index 3b35de381e017df6de77db10784db10a081fd19b..d8c49592965f0cb1f62654aed4bff87894c0269e 100644 (file)
@@ -7,55 +7,54 @@
  */
 package org.opendaylight.yangtools.yang.unified.doc.generator
 
-import org.opendaylight.yangtools.yang.model.api.SchemaContext
+import java.io.BufferedWriter
 import java.io.File
-import java.util.Set
-import org.opendaylight.yangtools.yang.model.api.Module
 import java.io.IOException
+import java.io.OutputStreamWriter
+import java.text.SimpleDateFormat
+import java.util.ArrayList
+import java.util.Collection
+import java.util.HashMap
 import java.util.HashSet
-import java.io.BufferedWriter
-import java.io.OutputStreamWriter;
+import java.util.LinkedHashMap
+import java.util.List
+import java.util.Map
+import java.util.Set
+import org.opendaylight.yangtools.yang.common.QName
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
+import org.opendaylight.yangtools.yang.model.api.AugmentationTarget
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition
+import org.opendaylight.yangtools.yang.model.api.Module
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
+import org.opendaylight.yangtools.yang.model.api.SchemaContext
 import org.opendaylight.yangtools.yang.model.api.SchemaNode
-import org.opendaylight.yangtools.yang.model.util.ExtendedType
-import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition
-import java.text.SimpleDateFormat
-import java.util.Collection
-import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint
+import org.opendaylight.yangtools.yang.model.api.SchemaPath
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition
+import org.opendaylight.yangtools.yang.model.api.UsesNode
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition
-import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer
-import org.slf4j.LoggerFactory
+import org.opendaylight.yangtools.yang.model.util.ExtendedType
 import org.slf4j.Logger
-import java.util.List
-import org.opendaylight.yangtools.yang.common.QName
-import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition
-import java.util.ArrayList
-import java.util.Map
-import org.opendaylight.yangtools.yang.model.api.SchemaPath
-
-import org.sonatype.plexus.build.incremental.BuildContext;
-import org.sonatype.plexus.build.incremental.DefaultBuildContext;
-
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates
-import java.util.LinkedHashMap
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode\rimport java.util.HashMap
-import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
-import org.opendaylight.yangtools.yang.model.api.UsesNode
-import org.opendaylight.yangtools.yang.model.api.GroupingDefinition
-import org.opendaylight.yangtools.yang.model.api.AugmentationTarget
+import org.slf4j.LoggerFactory
+import org.sonatype.plexus.build.incremental.BuildContext
+import org.sonatype.plexus.build.incremental.DefaultBuildContext
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
+import com.google.common.collect.Iterables
 
 class GeneratorImpl {
 
@@ -66,6 +65,10 @@ class GeneratorImpl {
     var Module currentModule;
     val Map<String, String> imports = new HashMap();
     var SchemaContext ctx;
+    
+    StringBuilder augmentChildNodesAsString
+    
+    DataSchemaNode lastNodeInTargetPath = null
 
     def generate(SchemaContext context, File targetPath, Set<Module> modulesToGen) throws IOException {
         path = targetPath;
@@ -301,13 +304,14 @@ class GeneratorImpl {
         }
         return '''
             <h2>Augmentations</h2>
-
+            
             <ul>
             «FOR augment : module.augmentations»
                 <li>
                     <h3 id="«schemaPathToString(module, augment.targetPath, context, augment)»">
                     Target [«typeAnchorLink(augment.targetPath,schemaPathToString(module, augment.targetPath, context, augment))»]</h3>
                     «augment.description»
+                        Status: «strong(String.valueOf(augment.status))»
                     «IF augment.reference !== null»
                         Reference «augment.reference»
                     «ENDIF»
@@ -317,11 +321,166 @@ class GeneratorImpl {
                     «FOR childNode : augment.childNodes»
                         «childNode.printSchemaNodeInfo»
                     «ENDFOR»
+                    
+                    <h3>Example</h3>
+                    «createAugmentChildNodesAsString(new ArrayList(augment.childNodes))»
+                    «printNodeChildren(parseTargetPath(augment.targetPath))»
                 </li>
             «ENDFOR»
             </ul>
         '''
     }
+    
+    private def createAugmentChildNodesAsString(List<DataSchemaNode> childNodes) {
+        augmentChildNodesAsString = new StringBuilder();
+        augmentChildNodesAsString.append(printNodeChildren(childNodes))
+        return ''
+    }
+    
+    private def parseTargetPath(SchemaPath path) {
+        val List<DataSchemaNode> nodes = new ArrayList<DataSchemaNode>();
+        for (QName pathElement : path.pathFromRoot) {
+            val module = ctx.findModuleByNamespaceAndRevision(pathElement.namespace, pathElement.revision);
+            if (module !== null) {
+                var foundNode = module.getDataChildByName(pathElement)
+                if(foundNode == null) {
+                    val child = nodes.last
+                    if (child instanceof DataNodeContainer) {
+                        val dataContNode = child as DataNodeContainer
+                        foundNode = findNodeInChildNodes(pathElement, dataContNode.childNodes)
+                    }
+                }
+                if(foundNode != null) {
+                    nodes.add(foundNode);
+                }
+            }
+        }
+        if(! nodes.empty) {
+            lastNodeInTargetPath = nodes.get(nodes.size() - 1)
+        }
+        
+        val List<DataSchemaNode> targetPathNodes = new ArrayList<DataSchemaNode>();
+        targetPathNodes.add(lastNodeInTargetPath)
+        
+        return targetPathNodes
+    }
+    
+    private def DataSchemaNode findNodeInChildNodes(QName findingNode, Iterable<DataSchemaNode> childNodes) {
+        for(child : childNodes) {
+            if (child.QName.equals(findingNode))
+                return child;
+        }
+        // find recursively
+        for(child : childNodes) {
+            if(child instanceof ContainerSchemaNode) {
+                val contChild = child as ContainerSchemaNode
+                val foundChild = findNodeInChildNodes(findingNode, contChild.childNodes)
+                if (foundChild != null)
+                    return foundChild;
+            }
+            else if(child instanceof ListSchemaNode) {
+                val listChild = child as ListSchemaNode
+                val foundChild = findNodeInChildNodes(findingNode, listChild.childNodes)
+                if (foundChild != null)
+                    return foundChild;
+            }
+        }
+    }
+    
+    private def printNodeChildren(List<DataSchemaNode> childNodes) {
+        if (childNodes.empty) {
+            return ''
+        }
+        
+        return 
+        '''
+        <pre>
+        «printAugmentedNode(childNodes.get(0))»
+        </pre>
+        '''
+    }
+    
+    private def printAugmentedNode(DataSchemaNode child) {
+        
+        if(child instanceof ChoiceCaseNode)
+            return ''
+            
+        return
+        '''
+        «IF child instanceof ContainerSchemaNode»
+            «printContainerNode(child as ContainerSchemaNode)»
+        «ENDIF»
+        «IF child instanceof AnyXmlSchemaNode»
+            «printAnyXmlNode(child as AnyXmlSchemaNode)»
+        «ENDIF»
+        «IF child instanceof LeafSchemaNode»
+            «printLeafNode(child as LeafSchemaNode)»
+        «ENDIF»
+        «IF child instanceof LeafListSchemaNode»
+            «printLeafListNode(child as LeafListSchemaNode)»
+        «ENDIF»
+        «IF child instanceof ListSchemaNode»
+            «printListNode(child as ListSchemaNode)»
+        «ENDIF»
+        «IF child instanceof ChoiceNode»
+            «printChoiceNode(child as ChoiceNode)»
+        «ENDIF»
+        '''
+    }
+    
+    private def printChoiceNode(ChoiceNode child) {
+        val List<ChoiceCaseNode> cases = new ArrayList(child.cases);
+        if(!cases.empty) {
+            val ChoiceCaseNode aCase = cases.get(0)
+            for(caseChildNode : aCase.childNodes)
+                printAugmentedNode(caseChildNode)
+        }
+    }
+    
+    private def printListNode(ListSchemaNode listNode) {
+        return
+        '''
+            &lt;«listNode.QName.localName»«IF !listNode.QName.namespace.equals(currentModule.namespace)» xmlns="«listNode.QName.namespace»"«ENDIF»&gt;
+                «FOR child : listNode.childNodes»
+                    «printAugmentedNode(child)»
+                «ENDFOR»
+            &lt;/«listNode.QName.localName»&gt;
+        '''
+    }
+    
+    private def printContainerNode(ContainerSchemaNode containerNode) {
+        return
+        '''
+            &lt;«containerNode.QName.localName»«IF !containerNode.QName.namespace.equals(currentModule.namespace)» xmlns="«containerNode.QName.namespace»"«ENDIF»&gt;
+                «FOR child : containerNode.childNodes»
+                    «printAugmentedNode(child)»
+                «ENDFOR»
+            &lt;/«containerNode.QName.localName»&gt;
+        '''
+    }
+    
+    private def printLeafListNode(LeafListSchemaNode leafListNode) {
+        return
+        '''
+            &lt;«leafListNode.QName.localName»&gt;. . .&lt;/«leafListNode.QName.localName»&gt;
+            &lt;«leafListNode.QName.localName»&gt;. . .&lt;/«leafListNode.QName.localName»&gt;
+            &lt;«leafListNode.QName.localName»&gt;. . .&lt;/«leafListNode.QName.localName»&gt;
+        '''
+    }
+    
+    private def printAnyXmlNode(AnyXmlSchemaNode anyXmlNode) {
+        return 
+        '''
+            &lt;«anyXmlNode.QName.localName»&gt;. . .&lt;/«anyXmlNode.QName.localName»&gt;
+        '''
+    }
+    
+    private def printLeafNode(LeafSchemaNode leafNode) {
+        return 
+        '''
+            &lt;«leafNode.QName.localName»&gt;. . .&lt;/«leafNode.QName.localName»&gt;
+        '''
+    }
 
     private def augmentationsSummary(Module module, SchemaContext context) {
         if (module.augmentations.empty) {
@@ -595,15 +754,15 @@ class GeneratorImpl {
 
     def CharSequence tree(Module module) '''
         «strong(module.name)»
-        «module.childNodes.treeSet(InstanceIdentifier.builder.toInstance())»
+        «module.childNodes.treeSet(YangInstanceIdentifier.builder.toInstance())»
     '''
 
-    private def dispatch CharSequence tree(ChoiceNode node,InstanceIdentifier path) '''
+    private def dispatch CharSequence tree(ChoiceNode node,YangInstanceIdentifier path) '''
         «node.nodeName» (choice)
         «casesTree(node.cases,path)»
     '''
 
-    def casesTree(Set<ChoiceCaseNode> nodes,InstanceIdentifier path) '''
+    def casesTree(Set<ChoiceCaseNode> nodes,YangInstanceIdentifier path) '''
         <ul>
         «FOR node : nodes»
             <li>
@@ -614,17 +773,17 @@ class GeneratorImpl {
         </ul>
     '''
 
-    private def dispatch CharSequence tree(DataSchemaNode node,InstanceIdentifier path) '''
+    private def dispatch CharSequence tree(DataSchemaNode node,YangInstanceIdentifier path) '''
         «node.nodeName»
     '''
 
-    private def dispatch CharSequence tree(ListSchemaNode node,InstanceIdentifier path) '''
+    private def dispatch CharSequence tree(ListSchemaNode node,YangInstanceIdentifier path) '''
         «val newPath = path.append(node)»
         «localLink(newPath,node.nodeName)»
         «node.childNodes.treeSet(newPath)»
     '''
 
-    private def dispatch CharSequence tree(ContainerSchemaNode node,InstanceIdentifier path) '''
+    private def dispatch CharSequence tree(ContainerSchemaNode node,YangInstanceIdentifier path) '''
         «val newPath = path.append(node)»
         «localLink(newPath,node.nodeName)»
         «node.childNodes.treeSet(newPath)»
@@ -635,7 +794,7 @@ class GeneratorImpl {
         «IF !childNodes.nullOrEmpty»
             <h2>Child nodes</h2>
 
-            «childNodes.printChildren(3,InstanceIdentifier.builder().toInstance())»
+            «childNodes.printChildren(3,YangInstanceIdentifier.builder().toInstance())»
         «ENDIF»
     '''
 
@@ -672,18 +831,15 @@ class GeneratorImpl {
 
     def String typeAnchorLink(SchemaPath path, CharSequence text) {
         if(path !== null) {
-            val prefix = path.path.last.prefix
-            if(prefix == this.currentModule.prefix) {
+            val lastElement = Iterables.getLast(path.pathFromRoot)
+            val ns = lastElement.namespace
+            if (ns == this.currentModule.namespace) {
                 return '''<a href="#«path.schemaPathToId»">«text»</a>'''
-            } else if(!prefix.nullOrEmpty){
-                val String module = imports.get(prefix)
-                if(!module.nullOrEmpty) {
-                    return '''«prefix»:«text»'''
-                    //to enable external (import) links
-                    //return '''<a href="«module».html#«path.schemaPathToId»">«prefix»:«text»</a>'''
-                }
+            } else {
+                return '''(«ns»)«text»'''
+                //to enable external (import) links
+                //return '''<a href="«module».html#«path.schemaPathToId»">«prefix»:«text»</a>'''
             }
-            return text.toString
         }
     }
 
@@ -767,7 +923,7 @@ class GeneratorImpl {
 
     def CharSequence printUses(UsesNode usesNode) {
         return '''
-            «strong(listItem("uses", typeAnchorLink(usesNode.groupingPath, usesNode.groupingPath.path.last.localName)))»
+            «strong(listItem("uses", typeAnchorLink(usesNode.groupingPath, usesNode.groupingPath.pathTowardsRoot.iterator.next.localName)))»
             <ul>
             <li>refines:
                 <ul>
@@ -789,7 +945,7 @@ class GeneratorImpl {
         '''
     }
 
-    def CharSequence printChildren(Set<DataSchemaNode> nodes, int level, InstanceIdentifier path) {
+    def CharSequence printChildren(Iterable<DataSchemaNode> nodes, int level, YangInstanceIdentifier path) {
         val anyxmlNodes = nodes.filter(AnyXmlSchemaNode)
         val leafNodes = nodes.filter(LeafSchemaNode)
         val leafListNodes = nodes.filter(LeafListSchemaNode)
@@ -839,13 +995,13 @@ class GeneratorImpl {
         '''
     }
 
-    def CharSequence xmlExample(Set<DataSchemaNode> nodes, QName name,InstanceIdentifier path) '''
+    def CharSequence xmlExample(Iterable<DataSchemaNode> nodes, QName name,YangInstanceIdentifier path) '''
     <pre>
         «xmlExampleTag(name,nodes.xmplExampleTags(path))»
     </pre>
     '''
 
-    def CharSequence xmplExampleTags(Set<DataSchemaNode> nodes, InstanceIdentifier identifier) '''
+    def CharSequence xmplExampleTags(Iterable<DataSchemaNode> nodes, YangInstanceIdentifier identifier) '''
         <!-- Child nodes -->
         «FOR node : nodes»
         <!-- «node.QName.localName» -->
@@ -854,29 +1010,29 @@ class GeneratorImpl {
 
     '''
 
-    private def dispatch CharSequence asXmlExampleTag(LeafSchemaNode node, InstanceIdentifier identifier) '''
+    private def dispatch CharSequence asXmlExampleTag(LeafSchemaNode node, YangInstanceIdentifier identifier) '''
         «node.QName.xmlExampleTag("...")»
     '''
 
-    private def dispatch CharSequence asXmlExampleTag(LeafListSchemaNode node, InstanceIdentifier identifier) '''
+    private def dispatch CharSequence asXmlExampleTag(LeafListSchemaNode node, YangInstanceIdentifier identifier) '''
         &lt!-- This node could appear multiple times --&gt
         «node.QName.xmlExampleTag("...")»
     '''
 
-    private def dispatch CharSequence asXmlExampleTag(ContainerSchemaNode node, InstanceIdentifier identifier) '''
+    private def dispatch CharSequence asXmlExampleTag(ContainerSchemaNode node, YangInstanceIdentifier identifier) '''
         &lt!-- See «localLink(identifier.append(node),"definition")» for child nodes.  --&gt
         «node.QName.xmlExampleTag("...")»
     '''
 
 
-    private def dispatch CharSequence asXmlExampleTag(ListSchemaNode node, InstanceIdentifier identifier) '''
+    private def dispatch CharSequence asXmlExampleTag(ListSchemaNode node, YangInstanceIdentifier identifier) '''
         &lt!-- See «localLink(identifier.append(node),"definition")» for child nodes.  --&gt
         &lt!-- This node could appear multiple times --&gt
         «node.QName.xmlExampleTag("...")»
     '''
 
 
-    private def dispatch CharSequence asXmlExampleTag(DataSchemaNode node, InstanceIdentifier identifier) '''
+    private def dispatch CharSequence asXmlExampleTag(DataSchemaNode node, YangInstanceIdentifier identifier) '''
         <!-- noop -->
     '''
 
@@ -888,7 +1044,7 @@ class GeneratorImpl {
     def header(int level,QName name) '''<h«level»>«name.localName»</h«level»>'''
 
 
-    def header(int level,InstanceIdentifier name) '''
+    def header(int level,YangInstanceIdentifier name) '''
         <h«level» id="«FOR cmp : name.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»">
             «FOR cmp : name.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»
         </h«level»>
@@ -896,11 +1052,11 @@ class GeneratorImpl {
 
 
 
-    private def dispatch CharSequence printInfo(DataSchemaNode node, int level, InstanceIdentifier path) '''
+    private def dispatch CharSequence printInfo(DataSchemaNode node, int level, YangInstanceIdentifier path) '''
         «header(level+1,node.QName)»
     '''
 
-    private def dispatch CharSequence printInfo(ContainerSchemaNode node, int level, InstanceIdentifier path) '''
+    private def dispatch CharSequence printInfo(ContainerSchemaNode node, int level, YangInstanceIdentifier path) '''
         «val newPath = path.append(node)»
         «header(level,newPath)»
         <dl>
@@ -912,7 +1068,7 @@ class GeneratorImpl {
         «node.childNodes.printChildren(level,newPath)»
     '''
 
-    private def dispatch CharSequence printInfo(ListSchemaNode node, int level, InstanceIdentifier path) '''
+    private def dispatch CharSequence printInfo(ListSchemaNode node, int level, YangInstanceIdentifier path) '''
         «val newPath = path.append(node)»
         «header(level,newPath)»
         <dl>
@@ -924,46 +1080,68 @@ class GeneratorImpl {
         «node.childNodes.printChildren(level,newPath)»
     '''
 
-    private def dispatch CharSequence printInfo(ChoiceNode node, int level, InstanceIdentifier path) '''
+    private def dispatch CharSequence printInfo(ChoiceNode node, int level, YangInstanceIdentifier path) '''
         «val Set<DataSchemaNode> choiceCases = new HashSet(node.cases)»
         «choiceCases.printChildren(level,path)»
     '''
 
-    private def dispatch CharSequence printInfo(ChoiceCaseNode node, int level, InstanceIdentifier path) '''
+    private def dispatch CharSequence printInfo(ChoiceCaseNode node, int level, YangInstanceIdentifier path) '''
         «node.childNodes.printChildren(level,path)»
     '''
 
 
 
-    def CharSequence printShortInfo(ContainerSchemaNode node, int level, InstanceIdentifier path) {
+    def CharSequence printShortInfo(ContainerSchemaNode node, int level, YangInstanceIdentifier path) {
         val newPath = path.append(node);
         return '''
-            <li>«strong(localLink(newPath,node.QName.localName))» (container)</li>
+            <li>«strong(localLink(newPath,node.QName.localName))» (container)
+            <ul>
+                <li>configuration data: «strong(String.valueOf(node.configuration))»</li>
+            </ul>
+            </li>
         '''
     }
 
-    def CharSequence printShortInfo(ListSchemaNode node, int level, InstanceIdentifier path) {
+    def CharSequence printShortInfo(ListSchemaNode node, int level, YangInstanceIdentifier path) {
         val newPath = path.append(node);
         return '''
-            <li>«strong(localLink(newPath,node.QName.localName))» (list)</li>
+            <li>«strong(localLink(newPath,node.QName.localName))» (list)
+            <ul>
+                <li>configuration data: «strong(String.valueOf(node.configuration))»</li>
+            </ul>
+            </li>
         '''
     }
 
-    def CharSequence printShortInfo(AnyXmlSchemaNode node, int level, InstanceIdentifier path) {
+    def CharSequence printShortInfo(AnyXmlSchemaNode node, int level, YangInstanceIdentifier path) {
         return '''
-            <li>«strong((node.QName.localName))» (anyxml)</li>
+            <li>«strong((node.QName.localName))» (anyxml)
+            <ul>
+                <li>configuration data: «strong(String.valueOf(node.configuration))»</li>
+                <li>mandatory: «strong(String.valueOf(node.constraints.mandatory))»</li>
+            </ul>
+            </li>
         '''
     }
 
-    def CharSequence printShortInfo(LeafSchemaNode node, int level, InstanceIdentifier path) {
+    def CharSequence printShortInfo(LeafSchemaNode node, int level, YangInstanceIdentifier path) {
         return '''
-            <li>«strong((node.QName.localName))» (leaf)</li>
+            <li>«strong((node.QName.localName))» (leaf)
+            <ul>
+                <li>configuration data: «strong(String.valueOf(node.configuration))»</li>
+                <li>mandatory: «strong(String.valueOf(node.constraints.mandatory))»</li>
+            </ul>
+            </li>
         '''
     }
 
-    def CharSequence printShortInfo(LeafListSchemaNode node, int level, InstanceIdentifier path) {
+    def CharSequence printShortInfo(LeafListSchemaNode node, int level, YangInstanceIdentifier path) {
         return '''
-            <li>«strong((node.QName.localName))» (leaf-list)</li>
+            <li>«strong((node.QName.localName))» (leaf-list)
+            <ul>
+                <li>configuration data: «strong(String.valueOf(node.configuration))»</li>
+            </ul>
+            </li>
         '''
     }
 
@@ -973,35 +1151,32 @@ class GeneratorImpl {
         '''
     }
 
-    def CharSequence localLink(InstanceIdentifier identifier, CharSequence text) '''
+    def CharSequence localLink(YangInstanceIdentifier identifier, CharSequence text) '''
         <a href="#«FOR cmp : identifier.path SEPARATOR "/"»«cmp.nodeType.localName»«ENDFOR»">«text»</a>
     '''
 
 
-    private def dispatch InstanceIdentifier append(InstanceIdentifier identifier, ContainerSchemaNode node) {
-        val pathArguments = new ArrayList(identifier.path)
-        pathArguments.add(new NodeIdentifier(node.QName));
-        return new InstanceIdentifier(pathArguments);
+    private def dispatch YangInstanceIdentifier append(YangInstanceIdentifier identifier, ContainerSchemaNode node) {
+        return identifier.node(node.QName);
     }
 
-    private def dispatch InstanceIdentifier append(InstanceIdentifier identifier, ListSchemaNode node) {
-        val pathArguments = new ArrayList(identifier.path)
+    private def dispatch YangInstanceIdentifier append(YangInstanceIdentifier identifier, ListSchemaNode node) {
         val keyValues = new LinkedHashMap<QName,Object>();
         if(node.keyDefinition !== null) {
             for(definition : node.keyDefinition) {
                 keyValues.put(definition,new Object);
             }
         }
-        pathArguments.add(new NodeIdentifierWithPredicates(node.QName,keyValues));
-        return new InstanceIdentifier(pathArguments);
+
+        return identifier.node(new NodeIdentifierWithPredicates(node.QName, keyValues));
     }
 
 
-    def asXmlPath(InstanceIdentifier identifier) {
+    def asXmlPath(YangInstanceIdentifier identifier) {
         return "";
     }
 
-    def asRestconfPath(InstanceIdentifier identifier) {
+    def asRestconfPath(YangInstanceIdentifier identifier) {
         val it = new StringBuilder();
         append(currentModule.name)
         append(":")
@@ -1012,7 +1187,7 @@ class GeneratorImpl {
             previous = true;
             if(arg instanceof NodeIdentifierWithPredicates) {
                 val nodeIdentifier = arg as NodeIdentifierWithPredicates;
-                for(qname : nodeIdentifier.keyValues.keySet) {
+                for(qname : nodeIdentifier.getKeyValues.keySet) {
                     append("/{");
                     append(qname.localName)
                     append("}")
@@ -1027,7 +1202,7 @@ class GeneratorImpl {
             val List<QName> path = schemaPath.path
         val StringBuilder pathString = new StringBuilder()
         if (schemaPath.absolute) {
-            pathString.append("/")
+            pathString.append('/')
         }
 
         val QName qname = path.get(0)
@@ -1053,17 +1228,12 @@ class GeneratorImpl {
                     }
                 }
 
-                var String prefix = name.prefix
-                var String moduleName
-                if (prefix == null || "".equals(prefix) || prefix.equals(module.prefix)) {
-                    moduleName = module.name
-                } else {
-                    moduleName = imports.get(prefix)
-                }
+                val pathElementModule = ctx.findModuleByNamespaceAndRevision(name.namespace, name.revision)
+                val String moduleName = pathElementModule.name
                 pathString.append(moduleName)
-                pathString.append(":")
+                pathString.append(':')
                 pathString.append(name.localName)
-                pathString.append("/")
+                pathString.append('/')
                 if(node instanceof ChoiceNode && dataNode !== null) {
                     val DataSchemaNode caseNode = dataNode.childNodes.findFirst[DataSchemaNode e | e instanceof ChoiceCaseNode];
                     if(caseNode !== null) {
@@ -1098,7 +1268,7 @@ class GeneratorImpl {
         «ENDIF»
     '''
 
-    private def CharSequence treeSet(Collection<DataSchemaNode> childNodes, InstanceIdentifier path) '''
+    private def CharSequence treeSet(Collection<DataSchemaNode> childNodes, YangInstanceIdentifier path) '''
         «IF childNodes !== null && !childNodes.empty»
             <ul>
             «FOR child : childNodes»
@@ -1121,7 +1291,7 @@ class GeneratorImpl {
         </ul>
     '''
 
-    private def dispatch CharSequence tree(Void obj, InstanceIdentifier path) '''
+    private def dispatch CharSequence tree(Void obj, YangInstanceIdentifier path) '''
     '''
 
 
@@ -1257,7 +1427,7 @@ class GeneratorImpl {
             var i = 0;
             for (pathElement : path) {
                 actual.add(pathElement)
-                val DataSchemaNode nodeByPath = childNodes.get(new SchemaPath(actual, absolute)) 
+                val DataSchemaNode nodeByPath = childNodes.get(SchemaPath.create(actual, absolute))
                 if (!(nodeByPath instanceof ChoiceNode) && !(nodeByPath instanceof ChoiceCaseNode)) {
                     result.append(pathElement.localName)
                     if (i != path.size - 1) {