I would like to read a BPMN file and parse it into a JSON object that I can work with in JavaScript.
Example: Small part of my test model
<bpmn:userTask id="Task_02kytkf" name="Open Packages Verify content">
<bpmn:documentation>Packages are opened, if no invoice or statement compare against web orders on AliExpress website.</bpmn:documentation>
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="order" value="20" />
<camunda:property name="title" value="Inspect packages, locae invoice" />
</camunda:properties>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_12iimor</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0xebhak</bpmn:outgoing>
</bpmn:userTask>
To a JSON object something like
{
"userTask": {
"documentation": {
"__prefix": "bpmn",
"__text": "Packages are opened, if no invoice or statement compare against web orders on AliExpress website."
},
"extensionElements": {
"properties": {
"property": [
{
"_name": "order",
"_value": "20",
"__prefix": "camunda"
},
{
"_name": "title",
"_value": "Inspect packages, locae invoice",
"__prefix": "camunda"
}
],
"__prefix": "camunda"
},
"__prefix": "bpmn"
},
"incoming": {
"__prefix": "bpmn",
"__text": "SequenceFlow_12iimor"
},
"outgoing": {
"__prefix": "bpmn",
"__text": "SequenceFlow_0xebhak"
},
"_id": "Task_02kytkf",
"_name": "Open\nPackages\nVerify content",
"__prefix": "bpmn"
}
}
Not certain if this is part of the BPMN-JS modules or something else.
Please provide some additional context. Do you want to parse the whole BPMN diagram or just parts of it?
I will parse the entire BPMN file. Those elements with the extra properties (Order, Title) will be processed further.
That’s exactly what bpmn-js and more specifically bpmn-moddle does.
Hope that helps.
Thank you, I’ve been looking into the bpmn-moddle to read a BPMN and identify all the elements of a select set (Ie: userTask, startEvent, serviceTask,…) Been drawn into unrelated projects and should get back to this one shortly.
I have done considerable research reviewing the BPMN-js and the BPMN-Moddle then expanding it to the camunda-bpmn-moodle and the camunda-bpmn-sdk and now I’ll admit I am completely lost.
I’m not a newbie and I should be able to understand this but the example all relate to adding something to the BPMN or displaying the diagram. Maybe what I’m trying to do isn’t possible.
I want to read the BPMN file. The file was created with Camunda and there are some additional properties added to the elements of the diagram.
I want to read through the elements of the BPMN file.
When I get a element<bpmn:userTask… I want to extract the value for <bpmn:documentation… and <camunda:property name=‘title’
then I want to read to the next <bpmn:userTask and repeat.
Here is small segment of the BPMN file I want to read.
<bpmn:userTask id="Task_0t7t1e0" name="Fill and Save">
<bpmn:documentation>The regular request form is updated with information. It can be saved and re-edited. The request can not be sumbitted until all the required information is entered and validated.</bpmn:documentation>
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="Input_05p0r37" />
</camunda:inputOutput>
<camunda:properties>
<camunda:property name="title" value="Enter details of request into the form. Saved request can be edited later." />
<camunda:property name="order" value="20" />
</camunda:properties>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_0nmu9jv</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0vvaob6</bpmn:outgoing>
<bpmn:standardLoopCharacteristics />
</bpmn:userTask>