Programmatically setting ConditionExpression on SequenceFlow

457 views
Skip to first unread message

Jaap Sperling

unread,
Mar 5, 2015, 3:20:06 AM3/5/15
to camunda-...@googlegroups.com
Hi,

I'm trying to write some code that automatically generates Camunda BPMN definition XML, and have run into a little snag. Hope someone can help.

First, I instantiate a SequenceFlow object from the model instance, and then I instantiate a ConditionExpression. I can add the actual expression by calling the #setTextcontent(String) method on the ConditionExpression, but that results in XML like

<conditionExpression id="conditionExpression_A_UUID">${x == 1}</conditionExpression>



To be valid (I think), the element also requires attribute xsi:type="tFormalExpression" but no matter what I try,
I registered the xsi namespace on the root Definitions instance (and if I don't do anything, the generated XML contains that namespace definition in the <definitions> element.

My unit test generates the document and then puts the model instance through Bpmn.validateModel

If I use conditionExpression.setAttributeValue("type", "tFormalExpression");
I get complex-type.3.2.2: Attribute 'type' is not allowed to appear in element 'conditionExpression'.

If I use conditionExpression.setAttributeValue("xsi:type", "tFormalExpression");
I get org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

If I use conditionExpression.setAttributeValueNs("http://www.w3.org/2001/XMLSchema-instance", "type", "tFormalExpression");
I get cvc-elt.4.2: Cannot resolve 'tFormalExpression' to a type definition for element 'conditionExpression'.

If I use conditionExpression.setAttributeValueNs("http://www.w3.org/2001/XMLSchema-instance", "xsi:type", "tFormalExpression");
I get org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

I've tried manipulating the underlying DomElement, but with the same results.

Anyone have any suggestions on how I can get this to work? Or is that xsi:type thing no longer required?

Thanks in advanced,

Jaap

Sebastian Menski

unread,
Mar 5, 2015, 3:59:45 AM3/5/15
to camunda-...@googlegroups.com
Hi Jaap,

which Version of the model API are you using? This should be fixed since 7.2.0 by this commit [1].

Cheers,
Sebastian 

Jaap Sperling

unread,
Mar 5, 2015, 5:05:20 AM3/5/15
to camunda-...@googlegroups.com
Sorry, forgot. Currently using the 7.3.0-alpha1 version.

Jaap

Jaap Sperling

unread,
Mar 5, 2015, 1:14:23 PM3/5/15
to camunda-...@googlegroups.com
Ok, an update.

I have just left out the xsi:type="tFormalExpression" and Bpmn.validateModel and Bpmn.convertToString do not complain. Furthermore, in unit test I have been able to deploy the model to our database and I can also start it.

Seems the attribute is not as mandatory as it used to be (at least, I remember from the Activiti documentation something that said "must be there and must be tFormalExpression").

Thanks to anyone that expended energy considering this issue.

Jaap
Reply all
Reply to author
Forward
0 new messages