我加载这个 DMN 文件(dmnFile):
<definitions name="MyDecision" id="def_12f8a48f-3978-0e29-4251-a66b6e6459bc"
xmlns:ns="http://sample.dmn" namespace="http://sample.dmn"
xmlns:feel="http://www.omg.org/spec/FEEL/20140401" exporter="ex" exporterVersion="12"
xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/">
<itemDefinition name="MyItemDefinition" id="_850f24d9-57a3-131f-2194-ca15bb049a7a">
<itemComponent name="myNumber" id="_29d92e98-3c97-67a3-22f1-d342622424f7">
<typeRef>NumberDefinition</typeRef>
</itemComponent>
</itemDefinition>
<itemDefinition name="NumberDefinition" id="_e6972775-7973-b755-8714-9eff9d61e48e">
<typeRef>number</typeRef>
</itemDefinition>
<inputData name="MyInput" id="_d6395e05-d35c-d667-f227-398d93a97759">
<variable name="MyInput" id="_121ab3bc-b4e2-a6bb-51be-ef8fcc6623a6" typeRef="MyItemDefinition" />
</inputData>
<decision name="MyDecision" id="_12f8a48f-3978-0e29-4251-a66b6e6459bc">
<variable name="MyDecision" id="_098e9619-fa0c-3796-b3da-c4d018a79009" typeRef="boolean" />
<informationRequirement>
<requiredInput href="#_d6395e05-d35c-d667-f227-398d93a97759" />
</informationRequirement>
<context id="_6dcdac84-b03f-badd-a2d7-78c668ece883">
<contextEntry>
<variable name="containsMyNumber" id="_f6078cbe-54e6-d682-b3b7-8ffc638e4846" typeRef="boolean" />
<literalExpression id="_a022013e-4f0c-cfb3-1792-673a9e69be33">
<text>if list contains([0,1,2,3], MyInput.myNumber) then true else false</text>
</literalExpression>
</contextEntry>
<contextEntry>
<literalExpression id="_19c3853c-c63b-a8ac-0608-639ea685f321">
<text>containsMyNumber</text>
</literalExpression>
</contextEntry>
</context>
</decision>
</definitions>
像这样:
KieServices ks = KieServices.Factory.get();
KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.2"), ks.getResources().newFileSystemResource(dmnFile));
我收到以下错误消息的异常:
[消息 [id=1, kieBase=defaultKieBase, level=ERROR, path=C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, line=4, column=-1 text= DMN: Unable to resolve type参考节点“MyItemDefinition”上的“{ http://www.omg.org/spec/DMN/20180521/MODEL/}NumberDefinition ” (资源:C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn,DMN id:_29d92e98-3c97-67a3-22f1-d342622424f7,未找到列出的类型定义)]]
带前缀的类型引用 ("ns:NumberDefinition") 会导致以下错误消息:
[消息 [id=1, kieBase=defaultKieBase, level=ERROR, path=C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn, line=4, column=-1 text= DMN: Unable to resolve type参考节点“MyItemDefinition”上的“{ http://www.omg.org/spec/DMN/20180521/MODEL/}ns:NumberDefinition ” (资源:C:/Users/AppData/Local/Temp/tmpBA10.tmp.dmn ,DMN id:_29d92e98-3c97-67a3-22f1-d342622424f7,未找到列出的类型定义)]]
我做错了什么?
当使用 DMN 1.1 (xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd") 并将引用类型作为 QNames(带前缀)时,我得到了预期的结果。