def export(self, validate=True):
self._finalize_batch()<EOL>ctrl_sum_total = <NUM_LIT:0><EOL>nb_of_txs_total = <NUM_LIT:0><EOL>for ctrl_sum in self._xml.iter('<STR_LIT>'):<EOL><INDENT>if ctrl_sum.text is None:<EOL><INDENT>continue<EOL><DEDENT>ctrl_sum_total += decimal_str_to_int(ctrl_sum.text)<EOL><DEDENT>for nb_of_txs in self._xml.iter('<STR_LIT>'):<EOL><INDENT>if nb_of_txs.text is None:<EOL><INDENT>continue<EOL><DEDENT>nb_of_txs_total += int(nb_of_txs.text)<EOL><DEDENT>n = self._xml.find(self.root_el)<EOL>GrpHdr_node = n.find('<STR_LIT>')<EOL>CtrlSum_node = GrpHdr_node.find('<STR_LIT>')<EOL>NbOfTxs_node = GrpHdr_node.find('<STR_LIT>')<EOL>CtrlSum_node.text = int_to_decimal_str(ctrl_sum_total)<EOL>NbOfTxs_node.text = str(nb_of_txs_total)<EOL>out = b"<STR_LIT>" + ET.tostring(<EOL>self._xml, "<STR_LIT:utf-8>")<EOL>if validate and not is_valid_xml(out, self.schema):<EOL><INDENT>raise ValidationError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>return out<EOL>
Method to output the xml as string. It will finalize the batches and
then calculate the checksums (amount sum and transaction count),
fill these into the group header and output the XML.