def parse(self): self.xml = ET.parse(self.name) for e in self.xml.findall('*'): if e.tag == slpsns.rpl_('title'): self.data.append(Title(e.text)) elif e.tag == slpsns.rpl_('message'): self.data.append(Message(e.text)) elif e.tag == slpsns.rpl_('step'): self.data.append(Step(e.text)) elif e.tag == slpsns.rpl_('tokens'): ts = TokenSeq() ts.parse(e) self.data.append(ts) else: print(e.tag)
def parse(self,elem): for e in elem.findall('*'): if e.tag == slpsns.rpl_('token'): if 'role' in e.attrib: self.data.append(Token(e.text,e.attrib['role'])) else: self.data.append(Token(e.text,'')) elif e.tag == slpsns.rpl_('line'): self.data.append(Line(e.text)) elif e.tag == slpsns.rpl_('tokens'): ts = TokenSeq() ts.parse(e) self.data.append(ts) else: print(e.tag)
def parse(self, elem): for e in elem.findall('*'): if e.tag == slpsns.rpl_('token'): if 'role' in e.attrib: self.data.append(Token(e.text, e.attrib['role'])) else: self.data.append(Token(e.text, '')) elif e.tag == slpsns.rpl_('line'): self.data.append(Line(e.text)) elif e.tag == slpsns.rpl_('tokens'): ts = TokenSeq() ts.parse(e) self.data.append(ts) else: print(e.tag)
def getXML(self): self.root = ET.Element(slpsns.rpl_('tokens')) for a in self.data: self.root.append(a.getXML()) return self.root
def getXML(self): self.root = ET.Element(slpsns.rpl_(self.tag)) self.root.text = self.data if self.role: self.root.attrib['role'] = self.role return self.root
def getXML(self): self.root = ET.Element(slpsns.rpl_('sequence')) for a in self.data: self.root.append(a.getXML()) return self.root