a778137beb615b4d369ceffa71861d6237835cb9
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-data-impl / src / test / resources / generateXml.groovy
1 //import groovy.xml.StreamingMarkupBuilder
2 import groovy.xml.MarkupBuilder
3 import groovy.xml.XmlUtil
4
5 class Counter {
6     def counter = 0
7     def get() {
8         return get(true)
9     }
10     def get(isInc) {
11         if (isInc) {
12             counter++
13         }
14         return String.format('%02d', counter)
15     }
16 }
17
18
19 cnt = new Counter()
20 def writer = new StringWriter()
21 xmlDoc = new MarkupBuilder(writer)
22 xmlDoc.setDoubleQuotes(true)
23 xmlDoc.getMkp().xmlDeclaration(version:'1.0', encoding: 'UTF-8')
24
25 //def data = {
26 //  mkp.xmlDeclaration()
27 //  network(xmlns: 'urn:opendaylight:controller:network') {
28 dataFile = new File(args[0])
29 evaluate(dataFile)
30 // xmlDoc.network(xmlns: 'urn:opendaylight:controller:network') {
31     // topologies {
32       // topology {
33         // 'topology-id'('topId_'+cnt.get())
34         // types()
35         // nodes {
36           // node {
37             // 'node-id'('nodeId_'+cnt.get())
38             // 'supporting-ne'('networkId_'+cnt.get())
39             // 'termination-points' {
40               // 'termination-point' {
41                 // 'tp-id'('tpId_'+cnt.get())
42               // }
43             // }
44           // }
45           // node {
46             // 'node-id'('nodeId_'+cnt.get())
47             // 'supporting-ne'('networkId_'+cnt.get())
48             // 'termination-points' {
49               // 'termination-point' {
50                 // 'tp-id'('tpId_'+cnt.get())
51               // }
52             // }
53           // }
54           // node {
55             // 'node-id'('nodeId_'+cnt.get())
56             // 'supporting-ne'('networkId_'+cnt.get())
57             // 'termination-points' {
58               // 'termination-point' {
59                 // 'tp-id'('tpId_'+cnt.get())
60               // }
61               // 'termination-point' {
62                 // 'tp-id'('tpId_'+cnt.get())
63               // }
64             // }
65           // }
66         // }
67         // links {
68           // link {
69             // 'link-id'('linkId_'+cnt.get())
70             // source {
71               // 'source-node'('nodeId_'+cnt.get())
72               // 'source-tp'('tpId_'+cnt.get(false))
73             // }
74             // destination {
75               // 'dest-node'('nodeId_'+cnt.get())
76               // 'dest-tp'('tpId_'+cnt.get(false))
77             // }
78           // }
79           // link {
80             // 'link-id'('linkId_'+cnt.get())
81             // source {
82               // 'source-node'('nodeId_'+cnt.get())
83               // 'source-tp'('tpId_'+cnt.get(false))
84             // }
85             // destination {
86               // 'dest-node'('nodeId_'+cnt.get())
87               // 'dest-tp'('tpId_'+cnt.get(false))
88             // }
89           // }
90         // }
91       // }
92     // }
93     // 'network-elements' {
94       // 'network-element' {
95         // 'element-id'('ntElementId_'+cnt.get())
96       // }
97       // 'network-element' {
98         // 'element-id'('ntElementId_'+cnt.get())
99       // }
100     // }
101   // }
102
103 //}
104
105
106 // def xmlDoc = new StreamingMarkupBuilder()
107 // xmlDoc.encoding = 'UTF'
108 //println XmlUtil.serialize(xmlDoc.bind(data))
109
110 println writer