dmn-moddle
v12.0.1
Published
A moddle wrapper for DMN 1.3
Readme
dmn-moddle
Read and write DMN 1.3 files in NodeJS and the browser.
dmn-moddle uses the DMN specification to validate the input and produce correct DMN XML. The library is built on top of moddle and moddle-xml.
Usage
Get the library via npm package. Consume it in NodeJS or bundle it using your favorite build tool.
import { DmnModdle } from 'dmn-moddle';
const moddle = new DmnModdle();
const xmlStr =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" ' +
'id="Definitions_1" ' +
'namespace="http://camunda.org/schema/1.0/dmn">' +
'<decision id="Decision_1" name="Decision" />' +
'</definitions>;
const {
rootElement: definitions
} = await moddle.fromXML(xmlStr);
// update id attribute
definitions.set('id', 'NEW ID');
// add a root element
const dmnDecision = moddle.create('dmn:Decision', { id: 'MyDecision' });
definitions.get('drgElement').push(dmnDecision);
// xmlStrUpdated contains new id and the added process
const {
xml: xmlStrUpdated
} = await moddle.toXML(definitions);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 testPerform a complete build of the library via
npm run allLicense
Use under the terms of the MIT license.
