Incorrect namespace when creating new elements by using bpmn model API

Hi,

For a part of my research project, I was trying to replace all inclusive gateways into parallel gateways and update corresponding arcs and references from a .bpmn model using BPMN model API.

During the implementation, however, I encountered a problem that when a new element is created, the name of the element can or can not get a prefix (e.g., the “bpmn:” prefix). For example:

<outgoing xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">StartEvent_1-translated_P_1</outgoing>

instead of:

<bpmn:outgoing>StartEvent_1-translated_P_1</bpmn:outgoing>

But it gets this prefix only if the namespaceURI of the new element and of the root element (the bpmn:definition element) are DIFFERENT. This is in method determinePrefixAndNamespaceUri() in class org.camunda.bpm

Please kindly advice that how can I get the correct namespace for newly created elements in the model. Below I attach two models that before the implementation and after the implementation (which is incorrect in namespace) respectively, together with my java code of the implementation.

afterChanging.bpmn (12.1 KB)
beforeChanging.bpmn (9.9 KB)
ORGatewayConventor.txt (5.1 KB)

Thanks,
Xiaoqing Hu

I still don’t know what’s the cause of this. But I solved the problem by employing replaceWithElement(newElement) instead of updating the arcs and references by manual coding. Now the graph is visible in camunda modeler.

I am facing the same problem with conditionExpression.
Can you explain how you created the newElement?
Is it by using the api(modelInstance.newInstance()) or by using dom element.

Hi @aakash, I am facing this exact same problem. I asked in the forum but got no answer.
Did you finally manage to include namespace when creating model/process via API?