+
+ 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 prefix = pathElement.prefix
+ val moduleName = imports.get(prefix)
+ if(moduleName != null) {
+ val revision = pathElement.revision
+ val module = ctx.findModuleByName(moduleName, revision)
+ 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
+ '''
+ <«listNode.QName.localName»«IF !listNode.QName.namespace.equals(currentModule.namespace)» xmlns="«listNode.QName.namespace»"«ENDIF»>
+ «FOR child : listNode.childNodes»
+ «printAugmentedNode(child)»
+ «ENDFOR»
+ </«listNode.QName.localName»>
+ '''
+ }
+
+ private def printContainerNode(ContainerSchemaNode containerNode) {
+ return
+ '''
+ <«containerNode.QName.localName»«IF !containerNode.QName.namespace.equals(currentModule.namespace)» xmlns="«containerNode.QName.namespace»"«ENDIF»>
+ «FOR child : containerNode.childNodes»
+ «printAugmentedNode(child)»
+ «ENDFOR»
+ </«containerNode.QName.localName»>
+ '''
+ }
+
+ private def printLeafListNode(LeafListSchemaNode leafListNode) {
+ return
+ '''
+ <«leafListNode.QName.localName»>. . .</«leafListNode.QName.localName»>
+ <«leafListNode.QName.localName»>. . .</«leafListNode.QName.localName»>
+ <«leafListNode.QName.localName»>. . .</«leafListNode.QName.localName»>
+ '''
+ }
+
+ private def printAnyXmlNode(AnyXmlSchemaNode anyXmlNode) {
+ return
+ '''
+ <«anyXmlNode.QName.localName»>. . .</«anyXmlNode.QName.localName»>
+ '''
+ }
+
+ private def printLeafNode(LeafSchemaNode leafNode) {
+ return
+ '''
+ <«leafNode.QName.localName»>. . .</«leafNode.QName.localName»>
+ '''
+ }