0

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?

Jankapunkt
  • 8,128
  • 4
  • 30
  • 59
prateeknaik
  • 71
  • 1
  • 7
  • Do you intend to refer to `bpmn-moddle` ? I am just asking because `bpmn-moodle` could refer to `MOODLE` which is an e-learning system. – Jankapunkt Mar 19 '20 at 07:32
  • bpmn-moodle refers to this github page - https://github.com/bpmn-io/bpmn-moddle. – prateeknaik Mar 19 '20 at 07:59
  • Does this answer your question? [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – AKX Mar 19 '20 at 08:04
  • I have tired that but doesnt work... still tat data is undefined. – prateeknaik Mar 19 '20 at 08:45

0 Answers0