Generate BPMN diagram on importing file without <bpmndi:BPMNDiagram> part

Hi everyone,

I am currently working on my own BPMN modeler, but I was getting a problem when importing an existing BPMN file without the bpmndi:BPMNDiagram part.

For example my input would be something like:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" >
  <process id="Process_1" isExecutable="false">
    <startEvent id="StartEvent_1" />
    <endEvent id="EndEvent_191tx7z" />
  </process>
</definitions>

But since the xml does not contain the bpmndi:BPMNDiagram part, my modeler could not render the file.

Is there any other API I could look into to solve my problem? Like auto generating a set of coordinates.

By the way, I can use bpmn-moddle to parse the xml to a Moddle tree, so the problem would also be converting a moddle tree to a renderable full xml.

Thanks!

There is an example implementation for that: https://github.com/bpmn-io/bpmn-moddle-auto-layout.
You could use this as a starting point.

Works like a charm, thanks!

1 Like