@staticmethod<EOL><INDENT>def export_xml_file(directory, filename, bpmn_diagram):<DEDENT>
diagram_attributes = bpmn_diagram.diagram_attributes<EOL>plane_attributes = bpmn_diagram.plane_attributes<EOL>collaboration = bpmn_diagram.collaboration<EOL>process_elements_dict = bpmn_diagram.process_elements<EOL>definitions = BpmnDiagramGraphExport.export_definitions_element()<EOL>[_, plane] = BpmnDiagramGraphExport.export_diagram_plane_elements(definitions, diagram_attributes,<EOL>plane_attributes)<EOL>if collaboration is not None and len(collaboration) > <NUM_LIT:0>:<EOL><INDENT>message_flows = collaboration[consts.Consts.message_flows]<EOL>participants = collaboration[consts.Consts.participants]<EOL>collaboration_xml = eTree.SubElement(definitions, consts.Consts.collaboration)<EOL>collaboration_xml.set(consts.Consts.id, collaboration[consts.Consts.id])<EOL>for message_flow_id, message_flow_attr in message_flows.items():<EOL><INDENT>message_flow = eTree.SubElement(collaboration_xml, consts.Consts.message_flow)<EOL>message_flow.set(consts.Consts.id, message_flow_id)<EOL>message_flow.set(consts.Consts.name, message_flow_attr[consts.Consts.name])<EOL>message_flow.set(consts.Consts.source_ref, message_flow_attr[consts.Consts.source_ref])<EOL>message_flow.set(consts.Consts.target_ref, message_flow_attr[consts.Consts.target_ref])<EOL>message_flow_params = bpmn_diagram.get_flow_by_id(message_flow_id)[<NUM_LIT:2>]<EOL>output_flow = eTree.SubElement(plane, BpmnDiagramGraphExport.bpmndi_namespace + consts.Consts.bpmn_edge)<EOL>output_flow.set(consts.Consts.id, message_flow_id + "<STR_LIT>")<EOL>output_flow.set(consts.Consts.bpmn_element, message_flow_id)<EOL>waypoints = message_flow_params[consts.Consts.waypoints]<EOL>for waypoint in waypoints:<EOL><INDENT>waypoint_element = eTree.SubElement(output_flow, "<STR_LIT>")<EOL>waypoint_element.set(consts.Consts.x, waypoint[<NUM_LIT:0>])<EOL>waypoint_element.set(consts.Consts.y, waypoint[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>for participant_id, participant_attr in participants.items():<EOL><INDENT>participant = eTree.SubElement(collaboration_xml, consts.Consts.participant)<EOL>participant.set(consts.Consts.id, participant_id)<EOL>participant.set(consts.Consts.name, participant_attr[consts.Consts.name])<EOL>participant.set(consts.Consts.process_ref, participant_attr[consts.Consts.process_ref])<EOL>output_element_di = eTree.SubElement(plane, BpmnDiagramGraphExport.bpmndi_namespace +<EOL>consts.Consts.bpmn_shape)<EOL>output_element_di.set(consts.Consts.id, participant_id + "<STR_LIT>")<EOL>output_element_di.set(consts.Consts.bpmn_element, participant_id)<EOL>output_element_di.set(consts.Consts.is_horizontal, participant_attr[consts.Consts.is_horizontal])<EOL>bounds = eTree.SubElement(output_element_di, "<STR_LIT>")<EOL>bounds.set(consts.Consts.width, participant_attr[consts.Consts.width])<EOL>bounds.set(consts.Consts.height, participant_attr[consts.Consts.height])<EOL>bounds.set(consts.Consts.x, participant_attr[consts.Consts.x])<EOL>bounds.set(consts.Consts.y, participant_attr[consts.Consts.y])<EOL><DEDENT><DEDENT>for process_id in process_elements_dict:<EOL><INDENT>process_element_attr = process_elements_dict[process_id]<EOL>process = BpmnDiagramGraphExport.export_process_element(definitions, process_id, process_element_attr)<EOL>if consts.Consts.lane_set in process_element_attr:<EOL><INDENT>BpmnDiagramGraphExport.export_lane_set(process, process_element_attr[consts.Consts.lane_set], plane)<EOL><DEDENT>nodes = bpmn_diagram.get_nodes_list_by_process_id(process_id)<EOL>for node in nodes:<EOL><INDENT>node_id = node[<NUM_LIT:0>]<EOL>params = node[<NUM_LIT:1>]<EOL>BpmnDiagramGraphExport.export_node_data(bpmn_diagram, node_id, params, process)<EOL><DEDENT>flows = bpmn_diagram.get_flows_list_by_process_id(process_id)<EOL>for flow in flows:<EOL><INDENT>params = flow[<NUM_LIT:2>]<EOL>BpmnDiagramGraphExport.export_flow_process_data(params, process)<EOL><DEDENT><DEDENT>nodes = bpmn_diagram.get_nodes()<EOL>for node in nodes:<EOL><INDENT>node_id = node[<NUM_LIT:0>]<EOL>params = node[<NUM_LIT:1>]<EOL>BpmnDiagramGraphExport.export_node_di_data(node_id, params, plane)<EOL><DEDENT>flows = bpmn_diagram.get_flows()<EOL>for flow in flows:<EOL><INDENT>params = flow[<NUM_LIT:2>]<EOL>BpmnDiagramGraphExport.export_flow_di_data(params, plane)<EOL><DEDENT>BpmnDiagramGraphExport.indent(definitions)<EOL>tree = eTree.ElementTree(definitions)<EOL>try:<EOL><INDENT>os.makedirs(directory)<EOL><DEDENT>except OSError as exception:<EOL><INDENT>if exception.errno != errno.EEXIST:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>tree.write(directory + filename, encoding='<STR_LIT:utf-8>', xml_declaration=True)<EOL>
Exports diagram inner graph to BPMN 2.0 XML file (with Diagram Interchange data).

:param directory: string representing output directory,
:param filename: string representing output file name,
:param bpmn_diagram: BPMNDiagramGraph class instantion representing a BPMN process diagram.