1 | # bpmn-moddle
|
2 |
|
3 | [![Build Status](https://travis-ci.org/bpmn-io/bpmn-moddle.svg?branch=master)](https://travis-ci.org/bpmn-io/bpmn-moddle)
|
4 |
|
5 | Read and write BPMN 2.0 diagram files in NodeJS and the browser.
|
6 |
|
7 | __bpmn-moddle__ uses the [BPMN 2.0 meta-model](http://www.omg.org/spec/BPMN/2.0/) to validate the input and produce correct BPMN 2.0 XML. The library is built on top of [moddle](https://github.com/bpmn-io/moddle) and [moddle-xml](https://github.com/bpmn-io/moddle-xml).
|
8 |
|
9 |
|
10 | ## Usage
|
11 |
|
12 | Get the library via [npm package](https://www.npmjs.org/package/bpmn-moddle). Bundle it for the web using [browserify](http://browserify.org) or [webpack](https://webpack.github.io).
|
13 |
|
14 | ```javascript
|
15 | var BpmnModdle = require('bpmn-moddle');
|
16 |
|
17 | var moddle = new BpmnModdle();
|
18 |
|
19 | var xmlStr =
|
20 | '<?xml version="1.0" encoding="UTF-8"?>' +
|
21 | '<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" id="empty-definitions" targetNamespace="http://bpmn.io/schema/bpmn">' +
|
22 | '</bpmn2:definitions>';
|
23 |
|
24 |
|
25 | moddle.fromXML(xmlStr, function(err, definitions) {
|
26 |
|
27 | // update id attribute
|
28 | definitions.set('id', 'NEW ID');
|
29 |
|
30 | // add a root element
|
31 | var bpmnProcess = moddle.create('bpmn:Process', { id: 'MyProcess_1' });
|
32 | definitions.get('rootElements').push(bpmnProcess);
|
33 |
|
34 | moddle.toXML(definitions, function(err, xmlStrUpdated) {
|
35 |
|
36 | // xmlStrUpdated contains new id and the added process
|
37 |
|
38 | });
|
39 |
|
40 | });
|
41 | ```
|
42 |
|
43 |
|
44 | ## Resources
|
45 |
|
46 | * [Issues](https://github.com/bpmn-io/bpmn-moddle/issues)
|
47 | * [Examples](https://github.com/bpmn-io/bpmn-moddle/tree/master/test/spec/xml)
|
48 |
|
49 |
|
50 | ## Building the Project
|
51 |
|
52 | To run the test suite that includes XSD schema validation you must have a Java JDK installed and properly exposed through the `JAVA_HOME` variable.
|
53 |
|
54 | Execute the test via
|
55 |
|
56 | ```
|
57 | npm test
|
58 | ```
|
59 |
|
60 | Perform a complete build of the application via
|
61 |
|
62 | ```
|
63 | npm run all
|
64 | ```
|
65 |
|
66 |
|
67 | ## License
|
68 |
|
69 | Use under the terms of the [MIT license](http://opensource.org/licenses/MIT). |
\ | No newline at end of file |