I have a problem to construct a query to match enumeration in multiple collection and I don’t know if it is possible (I know the existence of “collection()” function, but I can’t construct a working query)
My 2 schemas can be found at:
I have to put the organisation schema into another collection because in the future we want to connect to an LDAP server.
What I try to do is to find
- all contract Number
- where one of the responsibleUid is equal to an //organisationalPerson/cn, of a specified OrganisationalUnit or his subunits - ie:where OrganisationalUnit/ou = ‘toto’.
Is it possible to create a query to return this result?
As far as I understand your post you try to do a cross-collection join in order to retrieve all contracts that are related to a particular organisational unit.
I think the following query should do the job:
declare namespace ctC=?contract/contract?
declare namespace ctO="contract/contractOrganisation"
for $a in collection(?contractColl?)/ctC:contract
where for $b in collection(?contractOrg?)/ctO:contractOrganisation//ctO:OrganisationalUnit
where $b/ctO:ou =?toto? and $b//ctO:OrganisationalPerson/ctO:cn = $a/ctC:contractResponsibleUid
It iterates over all contracts and checks for each contract if there is an OrganizationalUnit named ?toto? that has an OrganisationalPerson that is referred by the ctC:contractResponsibleUid sequence. For each successfully checked contract the ID attribute is returned. Please be ware that I didn?t check the query with the Tamino XQuery processor. So it may contain some syntax or typing errors.