Use modeler-moddle to set executionPlatform


I am working with bpmn-js.

I have a Modeler instance named ‘bpmnJs’ which was created with the modeler-moddle as moddleExtensions parameter.

I would now like to set the ‘modeler:executionPlatform’ attribute which is part of the ‘bpmn:definitions’ XML tag.

I can create a new definitions tag by calling:

bpmnJs.get("moddle").create("bpmn:Definitions", {
            "modeler:executionPlatform": "Camunda Platform",
            "modeler:executionPlatformVersion": "7.15.0"

But what I would like to do is edit the existing definitions tag and add the ‘modeler:executionPlatform’ attribute. I can of course set it by hand using

bpmnJs.getDefinitions().set('modeler:executionPlatform', 'Camunda Platform')

but then I am missing the modeler namespace and did not make any use of modeler-moddle. I could add the namespace by hand as well, but this does not seem to be the right way to do it.

I guess what my question is:
From an existing BPMN XML missing the modeler namespace and the ‘modeler:executionPlatform’ attribute, how can I add and edit it using bpmn-js and modeler-moddle?
My goal is this:
<bpmn:definitions xmlns:xsi="" xmlns:bpmn="" xmlns:bpmndi="" xmlns:dc="" targetNamespace="" xmlns:modeler="" modeler:executionPlatform="Camunda Platform">

You’d add the modeler-moddle extension to the bpmn-moddle instance and set the modeler:executionPlatform property. The namespace will then be added automatically. Does this answer your question?

I have passed the modeler-moddle extension to a bpmn-js modeler instance during creation using the moddleExtensions option attribute. So:

var modelerModdle = require('modeler-moddle/resources/modeler');
var modelerModdleDescriptor= new BpmnModdle({ modeler: modelerModdle });

var bpmnJs = new BpmnModeler({
  container: '#js-canvas',
  keyboard: {
    bindTo: window
  moddleExtensions: {
    modeler: modelerModdleDescriptor

How would I proceed?

As far as I have found out, I can either use bpmnJs.get("moddle").create or bpmnJs.getDefinitions().set. The former creates a new bpmn:definitions tag, but I would like to keep the existing one and just add attributes. The latter did not add the modeler namespace in my tests.

You can use getDefinitions to get the root model element. You don’t have to add the namespace explicitly. Setting a property of that namespace (e.g. executionPlatform) will add the namespace to the XML automatically.