camunda / camunda-modeler

An integrated modeling solution for BPMN, DMN and Forms based on bpmn.io.
https://camunda.com/products/modeler
MIT License
1.49k stars 476 forks source link

BPMN with both the same namespace as default and named is broken at import #4190

Open barmac opened 5 months ago

barmac commented 5 months ago

Describe the bug

The Modeler breaks some BPMNs exported from JBPM, cf. https://forum.camunda.io/t/modeler-makes-a-lot-of-changes-to-file-even-for-small-change/51016

I noticed that in some cases the namespace is stripped:

-    <bpmn2:sequenceFlow id="_1-_jbpm-unique-218" tns:priority="1" name="" sourceRef="_1" targetRef="_jbpm-unique-218"/>
+    <bpmn2:sequenceFlow id="_1-_jbpm-unique-218" name="" sourceRef="_1" targetRef="_jbpm-unique-218" priority="1" />

Steps to reproduce

gh repo clone github.com/barmac/drools-bpmn-test
cd drools-bpmn-test
npm i
npm t

Expected behavior

BPMN should be valid after export.

Environment

plain bpmn-moddle

Additional context

No response

nikku commented 5 months ago

I'll have a look into this.

nikku commented 5 months ago

Initial assessment: The diagram does not break by saving, but breaks during import. As the original user reports there is a bunch of errors (attributes not known), which manifest in a broken BPMN 2.0 export later on.

Quoting from my user forum answer:

The problem stems from the fact that the example diagram declares default and prefixed usage for the same XML namespace:

xmlns:tns="http://www.jboss.org/drools" 
xmlns="http://www.jboss.org/drools" 

While this is not illegal usage it seems to confuse our importer regardless. As the diagram at hand does not use the default namespace it is safe to remove it. Afterwards the diagram imports (and serializes) without issues.

nikku commented 5 months ago

@barmac Removed from M75, let's follow up at a later stage.

barmac commented 5 months ago

I will update the issue title according to your assessment.

nikku commented 4 months ago

I reproduced this down to moddle-xml and saxen. As it touches the core of our infrastructure and XML de-serialization I can finally read the specs again :tada:. Will take some time.

ScottChapman commented 1 day ago

Any update on this? We have a lot of legacy model files which are difficult for us to migrate to modern versions of Camunda due to this. Thanks for consideration!