def to_xml(self): doc = BioDesDoc() bioport_id = self.get_biographies()[0].get_bioport_id() # add the basic onfirmation doc.from_args( naam_publisher='Het Biografisch Portaal', url_biografie='http://www.biografischportaal.nl/persoon/%s' % bioport_id, url_publisher='http://www.biografischportaal.nl', namen=self.get_names(), bioport_id=bioport_id, sex=self.get_value('sex'), ) # add the events for event_type in ['birth', 'death', 'funeral', 'baptism', 'floruit']: event = self.get_event(event_type) if event is not None: doc._add_event_element(event) # add illustrations for ill in self.get_illustrations(): doc._add_figure(url=ill.source_url, head=ill.caption) # add links to all sources for bio in self.get_biographies(): if bio.get_source().id != 'bioport': # construct a bibl element bibl = SubElement(doc.get_element_biography(), 'bibl') publisher = SubElement(bibl, 'publisher') publisher.text = bio.get_value('name_publisher') ref = SubElement(bibl, 'ref') ref.attrib['target'] = bio.get_value('url_biography') author = bio.get_value('author') if author: for s in author: el_author = SubElement(bibl, 'author') el_author.text = s return doc