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

Recursion problem

Michael Kay mike at saxonica.com
Fri Sep 7 11:42:55 PDT 2007


  Recursion problem
How do you know it is making n calls?

In principle the processor can call the function as often as it likes. It
might be inefficient, but it's not disallowed, so long as the results are
the same as calling it once.

You mention recursion in your title, but I don't see any recursion here.

It would be useful to give a sample input and your desired output, and show
how your actual output differs; also to give the whole query not just an
extract.

What product are you using?

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: http://x-query.com/mailman/listinfo/talk 
> [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of Jens-Martin Groenne
> Sent: 07 September 2007 09:55
> To: http://x-query.com/mailman/listinfo/talk
> Subject:  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>
> 
> };
> 
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk



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.