1

xqueryで情報を取得しようとしています。しかし、xml-element には名前のコロンがあります。

問題が名前空間で何かをしなければならないことは知っていますが、単純な xquery インタプリタを使用しているため、その方法がわかりません。

これが私のまさにアプローチですが、

let $e := doc('C:\Users\Katharina\workspace\BPMN\process_1.bpmn')
(: for $k in $e//*[name()='bpmn2:task']:)
for $k in $e
return $k

しかし、変更されたコードでは何も得られません..

XML ->

<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" targetNamespace="http://sample.bpmn2.org/bpmn2/sample/process">
  <bpmn2:itemDefinition id="ItemDefinition_2" itemKind="Physical" structureRef="I"/>
  <bpmn2:process id="process_1" name="Default Process">
    <bpmn2:task id="Task_2" name="Task 2">
      <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:parallelGateway id="ParallelGateway_1" name="Parallel Gateway 1" gatewayDirection="Diverging">
      <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing>
    </bpmn2:parallelGateway>
    <bpmn2:sequenceFlow id="SequenceFlow_9" name="Sequence Flow 9" sourceRef="Task_2" targetRef="ParallelGateway_1"/>
    <bpmn2:sequenceFlow id="SequenceFlow_10" sourceRef="ParallelGateway_1" targetRef="Task_3"/>
    <bpmn2:task id="Task_3" name="Task 3">
      <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:sequenceFlow id="SequenceFlow_11" sourceRef="ParallelGateway_1" targetRef="Task_4"/>
    <bpmn2:task id="Task_4" name="Task 4">
      <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:sequenceFlow id="SequenceFlow_12" sourceRef="Task_3" targetRef="ParallelGateway_2"/>
    <bpmn2:parallelGateway id="ParallelGateway_2" name="Parallel Gateway 2" gatewayDirection="Converging">
      <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing>
    </bpmn2:parallelGateway>
    <bpmn2:sequenceFlow id="SequenceFlow_13" name="Sequence Flow 13" sourceRef="Task_4" targetRef="ParallelGateway_2"/>
    <bpmn2:sequenceFlow id="SequenceFlow_14" sourceRef="ParallelGateway_2" targetRef="Task_5"/>
    <bpmn2:endEvent id="EndEvent_2" name="End Event 2">
      <bpmn2:incoming>SequenceFlow_15</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:task id="Task_5" name="Task 5">
      <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_15</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:sequenceFlow id="SequenceFlow_15" name="Sequence Flow 15" sourceRef="Task_5" targetRef="EndEvent_2"/>
    <bpmn2:startEvent id="StartEvent_2" name="Start Event 2">
      <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:sequenceFlow id="SequenceFlow_6" sourceRef="StartEvent_2" targetRef="Task_2"/>
  </bpmn2:process>
</bpmn2:definitions>
4

1 に答える 1

1

XQuery コードで名前空間 URI を宣言するだけです。

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

let $e := doc('C:\Users\Katharina\workspace\BPMN\process_1.bpmn')

for $k in $e//bpmn2:task
    return $k
于 2013-10-08T15:27:24.253 に答える