From: Faiyaz Ahmed Date: Fri, 9 Jan 2009 23:34:54 +0000 (+0000) Subject: i hate dom. X-Git-Tag: sfa-0.9-0@14641~755 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5b1329f3760ac4074f3c2cff3d65c2fd13e99f91;p=sfa.git i hate dom. --- diff --git a/rspec/rspecvalidate.py b/rspec/rspecvalidate.py index 8a0a4887..dcf07edc 100644 --- a/rspec/rspecvalidate.py +++ b/rspec/rspecvalidate.py @@ -16,4 +16,27 @@ import sys from xml.dom import minidom -# parse +def getText(nodelist): + rc = "" + for node in nodelist: + if node.nodeType == node.TEXT_NODE: + rc = rc + node.data + return rc + +# complexType: a supernode comprised of element nodes below it. +def traverseComplexType(cmpTypeNode): + _elements = {} + if cmpTypeNode.hasChildNodes(): + for n in cmpTypeNode.getElementsByTagName("xsd:attribute"): + _elements[n.getAttribute("name")] = {'type': n.getAttribute("type")} + +def buildDict(document): + if document.hasChildNodes(): + for i in document.childNodes: buildDict(i) + print document.localName + +def main(fname): + buildDict(minidom.parse(fname)) + +if __name__ == '__main__': + main(fname="planetlab.xsd")