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