Get XQuery Result with joined elements

Hello.

Can anybody give me a hint how i can query joined elemts including in a result document?


doctype order_id:
<order_id ino:id=“1” c_ob_id=“1” p_ob_id=“2”>
<order_id ino:id=“2” c_ob_id=“1” p_ob_id=“3”>
<order_id ino:id=“2” c_ob_id=“2” p_ob_id=“1”>

doctype customer:
c1
c2

doctype product:
p1
p2

The result should be something like that:

c1
p1
p2


c2
p1


I do not know how to solve it! :o(

Regards
Michael

Sorry that nobody answered your question earlier
(I was on vacation…)

I hope the following solution will help you.
Yo can test it with the latest version of quip (I
did not check earlier versions).

From this solution you can learn several things:

* a nice example of qualified expressions
* nested flower expressions
* computed element construction
* definition of utility function

Sven Eric

–snip------


define function removeAttr($el){
element {name($el)} {$el/node()}
}

let $orders :=
(<order_id ino:id=“1” c_ob_id=“1” p_ob_id=“2”/>
,<order_id ino:id=“2” c_ob_id=“1” p_ob_id=“1”/>
,<order_id ino:id=“2” c_ob_id=“2” p_ob_id=“1”/>
)

let $customers :=
(c1
,c2
)

let $products :=
(p1
,p2
)

for $c in $customers
return
{
removeAttr($c),
for $p in $products
where some $o in $orders
satisfies ($p/@ino:id = $o/@p_ob_id
and $c/@ino:id = $o/@c_ob_id)
return
removeAttr($p)
}