如何在BPMN文件中添加自定义XML标记?

时间:2015-06-10 16:02:33

标签: xml bpmn

在BPMN文件中有两个主要组件,即流程和图表。

<?xml version="1.0" encoding="UTF-8"?> 
<definitions id="Definition"
             targetNamespace="http://www.example.org/MinimalExample"
             typeLanguage="http://www.java.com/javaTypes"
             expressionLanguage="http://www.mvel.org/2.0"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
             xs:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
             xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
             xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
             xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
             xmlns:tns="http://www.jboss.org/drools">

  <process processType="Private" isExecutable="true" id="com.sample.HelloWorld" name="Hello World" >

    <!-- nodes -->
    <startEvent id="_1" name="StartProcess" />
    <scriptTask id="_2" name="Hello" >
      <script>System.out.println("Hello World");</script>
    </scriptTask>
    <endEvent id="_3" name="EndProcess" >
        <terminateEventDefinition/>
    </endEvent>

    <!-- connections -->
    <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
    <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />

  </process>

  <bpmndi:BPMNDiagram>
    <bpmndi:BPMNPlane bpmnElement="Minimal" >
      <bpmndi:BPMNShape bpmnElement="_1" >
        <dc:Bounds x="15" y="91" width="48" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_2" >
        <dc:Bounds x="95" y="88" width="83" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_3" >
        <dc:Bounds x="258" y="86" width="48" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_1-_2" >
        <di:waypoint x="39" y="115" />
        <di:waypoint x="75" y="46" />
        <di:waypoint x="136" y="112" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_2-_3" >
        <di:waypoint x="136" y="112" />
        <di:waypoint x="240" y="240" />
        <di:waypoint x="282" y="110" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>

</definitions>

我正在寻找一种在XML的图表部分之后添加第三部分的方法。我想添加自定义XML标记,以便我可以通过另一个系统运行XML并让该系统获取我的自定义XML。我一直在寻找一种方法来编辑&#34;定义&#34;标记包括第三部分,然后我可以添加任何XMl。是否有XMLSchema属性可以让我添加我的标签?我希望它看起来像这样:

<?xml version="1.0" encoding="UTF-8"?> 
<definitions id="Definition"...>

  <process .....  </process>

  <bpmndi:BPMNDiagram>
    <bpmndi:BPMNPlane bpmnElement="Minimal" >
      ......
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>

  <myNewSection>
    <newTag>
       <newTag2>
          ...
       </newTag2>
       <newTag3>
          ...
       </newTag3>
    </newTag>
  </myNewSection>
</definitions>

1 个答案:

答案 0 :(得分:1)

来自http://www.omg.org/spec/BPMN/20100501/BPMN20.xsd

<xsd:element name="definitions" type="tDefinitions"/>
<xsd:complexType name="tDefinitions">
    <xsd:sequence>
        <xsd:element ref="import" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="extension" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="rootElement" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="bpmndi:BPMNDiagram" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="relationship" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    ...
    <xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:complexType>

因为tDefinitions类型没有扩展tBaseElement,所以不能用extensionElements元素扩展它,但你可以随意包含你自己的属性扩展。

在查看http://www.omg.org/spec/BPMN/20100501/Semantic.xsd之后,似乎process元素实际上只是rootElement的substitutionGroup中的许多顶级元素之一。

也许去阅读XML Schema替换组,看看你是否可以利用外部模式进行挖掘,或者如果你必须能够修改源模式,在这种情况下你基本上要求BPMN规范。

希望这会有所帮助,如果您找到一种从架构外扩展定义元素的好方法,请报告回来。

相关问题