[xquery-talk] Recursion problem
Jens-Martin Groenne
dev at nullsec.net
Fri Sep 7 11:54:34 PDT 2007
I have a problem with the following code.
When I call this function it actually makes n calls to the functions
getCustomer and getAddress, where n is the number of customerIds and
addressIds in the Criteria.
Can anyone point out to me what I have done wrong?
Here is the code:
declare function tns:getCustomer($Criteria as element(ns30:Criteria)) as
element(ns28:Customer)*{
let $CustCustomers := ns32:getCustomer(
<ns33:CustCriteria>
{
for $customerId in
fn:distinct-values($Criteria/ns30:customerId)
return
<ns33:custId>{fn:data($customerId)}</ns33:custId>
}
</ns33:CustCriteria>
)
let $AddAddresses := ns7:getAddress(
<ns8:AddressGetCriteria>
{
for $addressId in
fn:distinct-values($Criteria/ns30:addressId)
return
<ns8:farId>{fn:data($addressId)}</ns8:farId>
}
</ns8:AddressGetCriteria>
)
for $searchCustomer in $Criteria
return
for $resultCustomer in $CustCustomers/ns28:Customer
where $searchCustomer/ns30:customerId =
$resultCustomer/ns28:customerId
return
<ns28:Customer>
{
for $Person in $resultCustomer/ns28:Person
return $Person
}
{
for $Organization in $resultCustomer/ns28:Organization
return $Organization
}
{
for $resultAddress in $AddAddresses
where $resultAddress/ns29:addressId =
$searchCustomer/ns30:addressId
return
$resultAddress
}
</ns28:Customer>
};
More information about the talk
mailing list