簡體   English   中英

用Javascript生成BPMN XML

[英]Generate BPMN XML with Javascript

我想生成一個像這樣的BPMN XML文件:

  <?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions     xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:process id="Process_1" isExecutable="false">
  <bpmn:startEvent id="StartEvent_1">
  <bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
    </bpmn:startEvent>
   <bpmn:task id="Task_1" name="Titulo111">
   <bpmn:incoming>SequenceFlow_1</bpmn:incoming>
 <extensionElements>abc</extensionElements>
</bpmn:task>
  <bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="Task_1" />
 </bpmn:process>
 <bpmndi:BPMNDiagram id="BPMNDiagram_1">
 <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
  <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
    <dc:Bounds x="173" y="102" width="36" height="36" />
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
    <dc:Bounds x="437" y="107" width="100" height="80" />
  </bpmndi:BPMNShape>
  <bpmndi:BPMNEdge id="SequenceFlow_1_di" bpmnElement="SequenceFlow_1">
    <di:waypoint xsi:type="dc:Point" x="209" y="120" />
    <di:waypoint xsi:type="dc:Point" x="323" y="120" />
    <di:waypoint xsi:type="dc:Point" x="323" y="147" />
    <di:waypoint xsi:type="dc:Point" x="437" y="147" />
    <bpmndi:BPMNLabel>
      <dc:Bounds x="278" y="123.5" width="90" height="20" />
    </bpmndi:BPMNLabel>
  </bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>

有沒有辦法用JavaScript做到這一點? 我嘗試使用createElement,但無法在“:”之后設置屬性,例如“ <bpmn:process ... ></bpmn:process>

提前致謝。

看一下bpmn.io項目( http://bpmn.io/ )。 它包括一個用於生成BPMN的JavaScript庫以及一個建模和渲染模塊(用於BPMN)。

僅供參考:冒號字符之前的文本表示XML名稱空間(在您的情況下為bpmn ),因此您需要確保將其添加到XML根元素中: xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"

您可能想看一下這篇文章 (從原始 文章中引用),以獲得有關如何在JS中使用名稱空間創建XML文檔的更多信息。

希望這可以幫助,

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM