I have the following XML code:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions>
<bpmn2:process>
...
<bpmn2:userTask id="UserTask_1" name="User Task 1">
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:userTask>
...
...
...
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_Process_1"bpmnElement="defaultPackage.NewProcess2">
...
<bpmndi:BPMNShape id="BPMNShape_UserTask_1" bpmnElement="UserTask_1">
<dc:Bounds height="50.0" width="110.0" x="165.0" y="205.0"/>
</bpmndi:BPMNShape>
...
...
...
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
For the node which is defined inside the tags, I want to get its coordinates, which are defined under
<bpmndi:BPMNShape id="BPMNShape_UserTask_1" bpmnElement="UserTask_1">
<dc:Bounds height="50.0" width="110.0" x="165.0" y="205.0"/>
</bpmndi:BPMNShape>
inside .
I wrote the following code :
ArrayList<String> bpmnElements = getElementAttributes("bpmndi:BPMNShape", "bpmnElement");
for (int j = 0; j < bpmnElements.size(); j++){
String bpmnElement = bpmnElements.get(j);
if(childnodelist.equals("bpmn2:task")){
ArrayList<String> idTask = getIds("bpmn2:task");
for(int l=0; l<idTask.size(); l++){
if(idTask.get(l).equals(bpmnElement)) //becouse the id attribute of bpmn2:userTask is equal to
// bpmnElement attribute of bpmndi:BPMNShape node
{
ArrayList<String> Xs = getElementAttributes ("dc:Bounds" , "x");
jw.key("x").value(Xs.get(j));
}
}
}
}
where getElementsAttributes(gets all the attributes of the specified element of a specific node) and getIds(gets the id of the specified node) are two methods I built before and are completely functional , but I don't get anything in the output ...