6.0.0 • Published 4 years ago

apmn-moddle v6.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

apmn-moddle

Read and write APMN diagram files in NodeJS and the browser.

apmn-moddle uses the APMN meta-model to validate the input and produce correct APMN XML.

Usage

Get the library via npm package. Consume it in NodeJS, via UMD or bundle it for the browser using your favorite module bundler.

import ApmnModdle from 'apmn-moddle';

var moddle = new ApmnModdle();

var xmlStr =
  '<?xml version="1.0" encoding="UTF-8"?>' +
  '<apmn:definitions xmlns:apmn="http://apmn.io/spec/APMN/MODEL" ' +
                     'id="empty-definitions" ' +
                     'targetNamespace="http://apmn.io/schema/apmn">' +
  '</apmn:definitions>';


moddle.fromXML(xmlStr, function(err, definitions) {

  // update id attribute
  definitions.set('id', 'NEW ID');

  // add a root element
  var apmnProcess = moddle.create('apmn:Process', { id: 'MyProcess_1' });
  definitions.get('rootElements').push(apmnProcess);

  moddle.toXML(definitions, function(err, xmlStrUpdated) {

    // xmlStrUpdated contains new id and the added process

  });

});

Resources

Building the Project

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.

Execute the test via

npm test

Perform a complete build of the application via

npm run all

Related

The library is built on top of moddle and moddle-xml.

License

Use under the terms of the MIT license.

6.0.0

4 years ago

5.1.9

5 years ago

5.1.8

5 years ago

5.1.7

5 years ago

5.1.6

5 years ago