[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Recursion problem

Jens-Martin Groenne dev at nullsec.net
Fri Sep 7 11:54:34 PDT 2007


  Recursion problem
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>

};



Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.