cancel
Showing results for 
Search instead for 
Did you mean: 

how to load a '.bpmn20.xml' file to a process object

coolstoneyoung
Champ in-the-making
Champ in-the-making
I have a idea that to design a template workflow  (serveral ".bpmn20.xml" file) to generate serveral workflows. But how to load  a ".bpmn20.xml" file to a org.activiti.bpmn.model.Process object? So that i can change or add something by dynamic  deployment.

Thanks!
3 REPLIES 3

trademak
Star Contributor
Star Contributor
You can use the convertToBpmnModel method from the BpmnXMLConverter class (activiti-bpmn-converter). This will give back a BpmnModel object that contains one or more Process objects.

Best regards,

Thanks Tijs!
It works!
But I don't know what 's exact meaning of the parameter "enableSafeBpmnXml".
<code>
(public BpmnModel convertToBpmnModel(InputStreamProvider inputStreamProvider, boolean validateSchema, boolean enableSafeBpmnXml)
</code>

Deployment passes when i set it "false". But when i set it "true", it throws an exception:
<code>
Caused by: java.lang.IllegalArgumentException: Source parameter of type 'javax.xml.transform.stax.StAXSource' is not accepted by this validator.
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
at javax.xml.validation.Validator.validate(Validator.java:127)
at org.activiti.bpmn.converter.BpmnXMLConverter.validateModel(BpmnXMLConverter.java:171)
at org.activiti.bpmn.converter.BpmnXMLConverter.convertToBpmnModel(BpmnXMLConverter.java:221)
… 28 more
</code>

Here is my bpmn template:
<code>
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="my-DynamicProcess" isExecutable="true">
    <startEvent id="start"></startEvent>
    <userTask id="task1" name="First task" activiti:assignee="fred">
    
    </userTask>
    <userTask id="task2" name="Second task" activiti:assignee="john"></userTask>
    <boundaryEvent id="boundaryEvent1" name="timeout" attachedToRef="task1" cancelActivity="true">
      <timerEventDefinition>
        <timeDuration>PT10S</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
    <endEvent id="end"></endEvent>
    <sequenceFlow id="sequenceFlow-b926b3a0-5602-4ef7-a86d-147ba4384be5" sourceRef="start" targetRef="task1"></sequenceFlow>
    <sequenceFlow id="sequenceFlow-16595d79-a20d-4d67-a879-6b3fe863269e" sourceRef="task1" targetRef="task2"></sequenceFlow>
    <sequenceFlow id="sequenceFlow-abab8416-9ed3-4961-904e-3e89f81bd42d" sourceRef="task2" targetRef="end"></sequenceFlow>
    <sequenceFlow id="sequenceFlow-278e3d51-c813-4dff-ad8e-a0b21c1444fe" sourceRef="boundaryEvent1" targetRef="end"></sequenceFlow>
  </process>

</definitions>
</code>

jbarrez
Star Contributor
Star Contributor
See http://activiti.org/userguide/index.html#advanced.safe.bpmn.xml

I'm not sure it is meant to call directly like that - might be the cause of the error.