join within a collection

I would appreciate any help with formulating a query joining documents within a collection.

The documents are along the lines of the following:
1.

2.



I’d like to be able to query for the second document by id, and then find the first document by joining the second’s idref to the first’s id.

I’ve tried the following with no success:

for $a in input()/entity
where tf:getInoId($a) = 2
return
for $b in input()/ENTITY
where $b[@id] = $a/SUBCLASS-OF[@idref]
return
$b

Hi,

In order to join the documents via the attributes ?idref? and ?id? you have to rewrite your join predicate:

for $a in input()/entity
where tf:getInoId($a) = 2
return
for $b in input()/ENTITY
where $b/@id = $a/SUBCLASS-OF/@idref
return
$b

Be sure that you have defined a standard index on the ?idref? attribute. Otherwise you will run into performance problems.

Best Regards,

Thorsten Fiebig