def from_xml(self, node, doc): for c in node.childNodes: if c.nodeType == c.ELEMENT_NODE: if c.nodeName == "object": o = Object() o.from_xml( c, doc ) self.objects.append( o )
def from_xml(self, node, doc): if node.nodeName == "grounding": for c in node.childNodes: if c.nodeType == c.ELEMENT_NODE: if c.nodeName == "grounding_set": for cc in c.childNodes: if cc.nodeType == cc.ELEMENT_NODE: if c.nodeName == "object": obj = Object() obj.from_xml( cc, doc ) elif c.nodeName == "region": reg = Region() reg.from_xml( cc, doc ) elif c.nodeName == "constraint": cons = Constraint() cons.from_xml( cc, doc )
def from_xml(self, node, doc): self.type = node.getAttribute("type") for c in node.childNodes: if c.nodeType == c.ELEMENT_NODE: if c.nodeName == "object": self.object = Object() self.object.from_xml( c, doc )
class Region(object): def __init__(self): self.type = None self.object = None def from_xml(self, node, doc): self.type = node.getAttribute("type") for c in node.childNodes: if c.nodeType == c.ELEMENT_NODE: if c.nodeName == "object": self.object = Object() self.object.from_xml( c, doc ) def to_xml(self, parentNode, doc): node = doc.createElement("region") parentNode.appendChild(node) node.setAttribute("type", self.type) if self.object != None: self.object.to_xml(node, doc)