Domanda

I hava Problem with Xquery

I have an XML document like this

<?xml version="1.0" encoding="UTF-8"?>
  <bpmn2:definitions .....">
  <bpmn2:process id="process_3" drools:version="1" drools:packageName="defaultPackage"drools:adHoc="false" name="Default Process" isExecutable="true">
    <bpmn2:startEvent id="StartEvent_1" name="">
      <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:endEvent id="EndEvent_1" name="">
      <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:sequenceFlow id="SequenceFlow_3" name="Sequence Flow 3" sourceRef="StartEvent_1" targetRef="ManualTask_1"/>
    <bpmn2:manualTask id="ManualTask_1" timeToComplete="300" name="Manual Task 1">
      <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
    </bpmn2:manualTask>
    <bpmn2:manualTask id="ManualTask_2" timeToComplete="200" name="Manual Task 2">
        <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
    </bpmn2:manualTask>
    <bpmn2:sequenceFlow id="SequenceFlow_1" name="Sequence Flow 1" sourceRef="ManualTask_1" targetRef="ManualTask_2"/>
       <bpmn2:sequenceFlow id="SequenceFlow_4" name="Sequence Flow 4" sourceRef="ManualTask_2" targetRef="EndEvent_1"/>
  </bpmn2:process>
</bpmn2:definitions>

I want to get the next element.(the outgoing sequenceflow from the last element should be de incoming element(sequenceflow) (so an manualTask or an EndEvent (or as its simplified something different) (All those elements have the tag incoming )

declare namespace bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL";

let $elements := doc('file:///C:\..\process3.txt')/bpmn2:definitions/bpmn2:process,
$e := $elements/bpmn2:startEvent
return  $elements[//bpmn2:incoming/node() = $e//bpmn2:outgoing]

This returns in BaseX just the complete $elements and not .. and at the moment I think much to difficult..

È stato utile?

Soluzione

Right now your $elements var just contains one element: the process element. What you want is for it to contain all children of that element, so that should be bpmn2:process/*

Then your $e variable also needs to change a bit (see below) and the // in you're last line should the .// because you want it to be evaluated in the context of the $elements variable.

The final query should be something like this:

declare namespace bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL";

let $elements := doc('file:///C:\..\process3.txt')/bpmn2:definitions/bpmn2:process/*,
$e := $elements[self::bpmn2:startEvent]
return  $elements[.//bpmn2:incoming/node() = $e//bpmn2:outgoing]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top