2 * Copyright (c) 2013 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 import groovy.xml.MarkupBuilder
9 import org.opendaylight.controller.yang.data.impl.MyNodeBuilder
12 * wrapper class - applies hardcoded builder on given data closure
14 class MyXmlGenerator {
19 myBuilder = MyNodeBuilder.newInstance();
22 MyNodeBuilder getBuilder() {
26 void buildTree(data) {
27 data.setDelegate(myBuilder)
32 * tests builder execution
34 static void main(args) {
37 network(xmlns: 'urn:opendaylight:controller:network') {
40 'topology-id'('topId_01')
44 'node-id'('nodeId_02')
45 'supporting-ne'('networkId_03')
46 'termination-points' {
53 'node-id'('nodeId_05')
54 'supporting-ne'('networkId_06')
55 'termination-points' {
62 'node-id'('nodeId_08')
63 'supporting-ne'('networkId_09')
64 'termination-points' {
76 'link-id'('linkId_12')
78 'source-node'('nodeId_13')
79 'source-tp'('tpId_13')
82 'dest-node'('nodeId_14')
87 'link-id'('linkId_15')
89 'source-node'('nodeId_16')
90 'source-tp'('tpId_16')
93 'dest-node'('nodeId_17')
102 'element-id'('ntElementId_18')
105 'element-id'('ntElementId_19')
112 def xmlGen = new MyXmlGenerator()
113 xmlGen.buildTree(data)
114 println xmlGen.getBuilder().getRootNode()