0

我有 Xquery 的问题

我有一个这样的 XML 文档

<?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>

我想获得下一个元素。(最后一个元素的传出序列流应该是传入元素(序列流)(因此是手动任务或 EndEvent (或作为其简化的不同的东西)(所有这些元素都有标签传入)

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]

这在 BaseX 中返回的只是完整的 $elements 而不是 .. 目前我认为很难..

4

1 回答 1

0

现在你的 $elements 变量只包含一个元素:流程元素。您想要的是它包含该元素的所有子元素,因此应该是 bpmn2:process/*

然后你的 $e 变量也需要改变一点(见下文),你最后一行中的 // 应该是 .// 因为你希望它在 $elements 变量的上下文中进行评估。

最终查询应该是这样的:

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]
于 2013-11-01T13:09:24.910 回答