I have function where I am using bpmn moddle to create bpmn xml.
Below is my function createFileData
import BpmnModdle from 'bpmn-moddle'
function createFileData(){
var moddle = new BpmnModdle()
var xmlStr =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
'id="empty-definitions" ' +
'targetNamespace="http://bpmn.io/schema/bpmn">' +
'</bpmn2:definitions>';
moddle.fromXML(xmlStr, function(err, definitions) {
// update id attribute
definitions.set('id', 'NEW ID');
moddle.toXML(definitions, function(err, xmlStrUpdated){
console.log(xmlStrUpdated)
})
})
return xmlStrUpdated
}
I am getting the output in the console.
I want the xml created to be returned, when ever the function is called.
But I am getting the value as undefined
and unable to return
data to below function.
import createFileData from './fileData.js'
function viewxml(){
var data = createFileData()
console.log(data)
}
Can anyone help me in understanding, how to return the xml created from moddle?