update sample xml
[sfa.git] / rspec / rspecvalidate.py
1 #!/usr/bin/python
2
3 # $HeadURL$
4 # $Id$
5
6 #
7 # Validate RSPEC hiearchy, values, types, and names using supplied xsd.
8 #
9 # Faiyaz Ahmed <faiyaza at cs dot princeton dot edu>
10 #
11 # Copyright 2009 Princeton University
12 # http://www.planet-lab.org
13 #
14
15 import sys
16 from xml.dom import minidom
17
18
19 def getText(nodelist):
20     rc = ""
21     for node in nodelist:
22         if node.nodeType == node.TEXT_NODE:
23             rc = rc + node.data
24     return rc
25
26 # complexType: a supernode comprised of element nodes below it.
27 def traverseComplexType(cmpTypeNode):
28         _elements = {}
29         if cmpTypeNode.hasChildNodes():
30                 for n in cmpTypeNode.getElementsByTagName("xsd:attribute"):
31                         _elements[n.getAttribute("name")] = {'type': n.getAttribute("type")}
32
33 def buildDict(document):
34         if document.hasChildNodes():
35                 for i in document.childNodes: buildDict(i)
36         print document.localName
37
38 def main(fname):
39         buildDict(minidom.parse(fname))
40
41 if __name__ == '__main__':  
42         main(fname="planetlab.xsd")