Example #1
0
def main():
    options = get_options()
    if options.type in ["nodes", "node", "nod"]:
        write_xml('nodes', 'node', options)
    elif options.type in ["edges", "edge", "edg"]:
        write_xml('edges', 'edge', options)
    elif options.type in ["connections", "connection", "con"]:
        write_xml('connections', 'connection', options)
    elif options.type in ["routes", "vehicles", "vehicle", "rou"]:
        write_xml('routes', 'vehicle', options, row2vehicle_and_route)
    elif options.type in ["flows", "flow"]:
        write_xml('routes', 'flow', options, row2vehicle_and_route)
    elif options.xsd:
        writeHierarchicalXml(xsd.XsdStructure(options.xsd), options)
Example #2
0
 def __init__(self, xsdFile, source, split):
     NestingHandler.__init__(self)
     self.tagDepths = {} # tag -> depth of appearance
     self.tagAttrs = collections.defaultdict(collections.OrderedDict) # tag -> set of attrs
     self.renamedAttrs = {} # (name, attr) -> renamedAttr
     self.attrs = {}
     self.depthTags = {} # child of root: depth of appearance -> tag list
     self.rootDepth = 1 if split else 0
     if xsdFile:
         self.xsdStruc = xsd.XsdStructure(xsdFile)
         if split:
             for ele in self.xsdStruc.root.children:
                 self.attrs[ele.name] = []
                 self.depthTags[ele.name] = [[]]
                 self.recursiveAttrFind(ele, ele, 1)
         else:
             self.attrs[self.xsdStruc.root.name] = []
             self.depthTags[self.xsdStruc.root.name] = []
             self.recursiveAttrFind(self.xsdStruc.root, self.xsdStruc.root, 0)
     else:
         self.xsdStruc = None
         xml.sax.parse(source, self)