0.3.1 • Published 11 months ago
ifml-moddle v0.3.1
ifml-moddle
Read and write IFML diagram files in NodeJS and the browser.
ifml-moddle uses the IFML meta-model to validate the input and produce correct IFML 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.
const moddle = new IfmlModdle();
const xmlStr =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<ifml:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ifml="http://www.omg.org/spec/IFML/20140301" xmlns:ifmldi="http://www.omg.org/spec/IFML/20130218/IFML-DI" xmlns:xmi="http://www.omg.org/spec/XMI/20131001">' +
'<ifml:iFMLModel>' +
'<ifml:interactionFlowModel id="_myModel" />' +
'</ifml:iFMLModel>' +
'<ifmldi:iFMLDiagram modelElement="_myModel" />' +
'</ifml:definitions>';
const {
rootElement: definitions
} = await moddle.fromXML(xmlStr);
// update id attribute
definitions.set('id', 'NEW ID');
// add a root element
const ifmlViewContainer = moddle.create('ifml:ViewContainer', {
id: 'MyContainer'
});
var modelElements = definitions.get('ifmlModel')[0].get('interactionFlowModel').get(
'interactionFlowModelElements');
modelElements.push(ifmlViewContainer);
moddle.toXML(definitions).then(function (xml) {
console.log(xml);
})
Resources
Building the Project
Execute the test via
npm test
Perform a complete build of the application via
npm run all
Related
The library is built based on bpmn-moddle and on top of moddle and moddle-xml.
License
Use under the terms of the MIT license.