Create Model: Add CDATA to custom extension elements

We have custom extension elements in our model where we store our metadata. For example, a task can contain a property of exception script in its extension element.

An example of such BPMN XML is attached.

Notify.bpmn (3.8 KB)

Notify

We also have a requirement of creating BPMN Model programmatically and we are doing it as per the below link:

https://docs.camunda.org/manual/7.7/user-guide/model-api/bpmn-model-api/create-a-model/

However, when we convert the modelInstance to an XML string, the value in the extension element is not added in CDATA. Is there a way to add the extension element information in the CDATA section?

Attached is the BPMN XML that is generated programmatically. If you see here, there is a property tag inside the extension elements whose value is NOT present in the CDATA section because of which it fails while loading.

Notify_Programmatically.bpmn (3.7 KB)

Notify_Programmatically

The custom property element is added as per the following link:

Here is the code for PDPropertyImpl for reference:

public class PDPropertyImpl extends BpmnModelElementInstanceImpl implements PDProperty {

protected static Attribute<String> nameAttribute;

public static void registerType(ModelBuilder modelBuilder) {
	// removed code for brevity
}

public PDPropertyImpl(ModelTypeInstanceContext instanceContext) {
	super(instanceContext);
}

public String getName() {
	return (String) nameAttribute.getValue(this);
}

public void setName(String camundaName) {
	nameAttribute.setValue(this, camundaName);
}

public String getValue() {
	return this.getTextContent();
}

public void setValue(String value) {
	this.setTextContent(value);
}

}

I guess the problem might be caused by the Model API, right? I’m really not sure whether it depends on our bpmn.io toolkit libraries.

Furthermore, seems to be a duplicate with your post inside the Camunda Forum.

Yes, I posted this question on Camunda forum later on realizing that it is related to Camunda Modeler API.

Can you please advise on what shall be done to the post here - close it?’

Thanks for your time and help!

1 Like

I guess only admins have the rights to close topics. Did it accordingly.