Katharina Kaiser
Katharina Kaiser

Reputation: 69

Xpath / Xquery with colon

I am trying to get some information with xquery. But the xml-element has a colon with the name

I do know that the problem has to do something with the namespace but as I am working with a simple xquery intepreter i am not sure how to.

Here is my very approach but with

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

But I don't get anything with the changed code..

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

Upvotes: 1

Views: 835

Answers (1)

Tomalak
Tomalak

Reputation: 338316

Just declare the namespace URI in your XQuery code.

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

Upvotes: 1

Related Questions