bpmn-moddle
Read and write BPMN 2.0 diagram files in NodeJS and the browser.
bpmn-moddle uses the BPMN 2.0 meta-model to validate the input and produce correct BPMN 2.0 XML.
Usage
Get the library via npm package. Consume it in NodeJS, via UMD or bundle it using your favorite build tool.
import BpmnModdle from 'bpmn-moddle';
const moddle = new BpmnModdle();
const xmlStr =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
'id="empty-definitions" ' +
'targetNamespace="http://bpmn.io/schema/bpmn">' +
'</bpmn2:definitions>';
const {
rootElement: definitions
} = await moddle.fromXML(xmlStr);
definitions.set('id', 'NEW ID');
const bpmnProcess = moddle.create('bpmn:Process', { id: 'MyProcess_1' });
definitions.get('rootElements').push(bpmnProcess);
const {
xml: xmlStrUpdated
} = await moddle.toXML(definitions);
Resources
Building the Project
The tests include XSD schema validation. They required you to have a Java SDK installed and exposed through the JAVA_HOME
variable.
npm test
npm run all
Related
The library is built on top of moddle and moddle-xml.
License
Use under the terms of the MIT license.