A moddle wrapper for BPMN 2.0
npm install 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.
Get the library via npm package. Consume it in NodeJS or bundle it using your favorite build tool.
``javascript
import { BpmnModdle } from 'bpmn-moddle';
const moddle = new BpmnModdle();
const xmlStr =
'' +
'
'targetNamespace="http://bpmn.io/schema/bpmn">' +
'';
const {
rootElement: definitions
} = await moddle.fromXML(xmlStr);
// update id attribute
definitions.set('id', 'NEW ID');
// add a root element
const bpmnProcess = moddle.create('bpmn:Process', { id: 'MyProcess_1' });
definitions.get('rootElements').push(bpmnProcess);
// xmlStrUpdated contains new id and the added process
const {
xml: xmlStrUpdated
} = await moddle.toXML(definitions);
`
The tests include XSD schema validation. They required you to have a Java SDK installed and exposed through the JAVA_HOME variable.
`bashexecute the test
npm test
The library is built on top of moddle and moddle-xml.
Use under the terms of the MIT license.