我最近将我的 bpmn-js 库更新到了 0.26.6 版。但是,既然我已经这样做了,我的图表就遇到了问题。
出于某种原因,在将图表解析为 XML 时,SequenceFlow 对象似乎有一个附加属性,如下所示:
<bpmn:sequenceFlow id="SequenceFlow_0itptjk" name="x===1" sourceRef="ExclusiveGateway_16fh3h3" targetRef="Task_10pxcz5" $type="bpmn:SequenceFlow">
<bpmn:conditionExpression language="JavaScript" xsi:type="bpmn:tFormalExpression">x===1</bpmn:conditionExpression>
</bpmn:sequenceFlow>
问题是 $type="bpmn:SequenceFlow" 不是有效的 XML,它没有通过验证。
{
"name": "FlowElement",
"isAbstract": true,
"superClass": [
"BaseElement"
],
"properties": [
{
"name": "name",
"isAttr": true,
"type": "String"
},
{
"name": "auditing",
"type": "Auditing"
},
{
"name": "monitoring",
"type": "Monitoring"
},
{
"name": "categoryValueRef",
"type": "CategoryValue",
"isMany": true,
"isReference": true
}
]
},{
"name": "SequenceFlow",
"superClass": [
"FlowElement"
],
"properties": [
{
"name": "isImmediate",
"isAttr": true,
"type": "Boolean"
},
{
"name": "conditionExpression",
"type": "Expression",
"xml": {
"serialize": "xsi:type"
}
},
{
"name": "sourceRef",
"type": "FlowNode",
"isAttr": true,
"isReference": true
},
{
"name": "targetRef",
"type": "FlowNode",
"isAttr": true,
"isReference": true
}
]
},{
"name": "BaseElement",
"isAbstract": true,
"properties": [
{
"name": "id",
"isAttr": true,
"type": "String",
"isId": true
},
{
"name": "documentation",
"type": "Documentation",
"isMany": true
},
{
"name": "extensionDefinitions",
"type": "ExtensionDefinition",
"isMany": true,
"isReference": true
},
{
"name": "extensionElements",
"type": "ExtensionElements"
}
]
}
正如你所看到的,这些都没有任何表明为什么要添加 $type 的东西。
过去有没有人遇到过这个问题?
- 编辑 -
做了一些测试后,似乎是在将条件表达式添加到 SequenceFlow 时添加了 $type 参数。否则,不添加属性,并且 XML 有效。
--EDIT2--
这些是我正在使用的 XML 定义:
<bpmn:definitions id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
--EDIT3--
更多故障排除后的更多细节。似乎此错误不仅影响条件流 - 它影响所有类型。该错误恰好发生在更新之后,该更新在
UpdatePropertiesHandler.prototype.execute = function(context) ...
在该函数内部,有一个调用
setProperties(businessObject, properties);
在那套里面,有这个
function setProperties(businessObject, properties) {
forEach(properties, function(value, key) {
businessObject.set(key, value);
});
}
在forEach 之后,businessObject 突然在其$attrs 中有一个$type。就好像它不是在做businessObject.set,而是在做businessObject.$attr.set。