[英]Generate BPMN XML with Javascript
i want to generate an BPMN XML file like these: 我想生成一个像这样的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>
Is there any way to do this with javascript? 有没有办法用JavaScript做到这一点? I tried with createElement but i can't set the attribute after the ":" like " <bpmn:process ... ></bpmn:process>
" 我尝试使用createElement,但无法在“:”之后设置属性,例如“ <bpmn:process ... ></bpmn:process>
”
Thanks in advance. 提前致谢。
Take a look at the bpmn.io project ( http://bpmn.io/ ). 看一下bpmn.io项目( http://bpmn.io/ )。 It includes a javascript library to generate BPMN as well as a modeling and rendering module (for BPMN). 它包括一个用于生成BPMN的JavaScript库以及一个建模和渲染模块(用于BPMN)。
FYI: the text before the colon character denotes a XML name space ( bpmn
in your case) so you will need to make sure that you add it to your XML root element: xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
仅供参考:冒号字符之前的文本表示XML名称空间(在您的情况下为bpmn
),因此您需要确保将其添加到XML根元素中: xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
You may want to take a look at this article (quoted from this original post ) for more information on how to create a XML document with name spaces in JS. 您可能想看一下这篇文章 (从原始 文章中引用),以获得有关如何在JS中使用名称空间创建XML文档的更多信息。
Hope this helps, 希望这可以帮助,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.