|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Recursion problemJens-Martin Groenne dev at nullsec.netFri Sep 7 13:32:42 PDT 2007
Thank you for answering so quickly! We are using BEA Aqualogic DSP as the processor and the two functions that are called multiple times are again in calling webservices, thats why we do not want them to call multiple times as this makes the function useless due to too large responsetimes. I have changed the query according to your sudgestions, and also include the whole function that calls it. The main function is the top one and it is invoked as a dataservice. declare function tns:getCustomer($CustomerGetCriteria as element(ns30:CustomerGetCriteria)) as element(ns28:Customers)* { <ns28:Customers> { let $Criteria := $CustomerGetCriteria return if ($CustomerGetCriteria/ns30:returnAddress=true()) then ( tns:fixedCustomeraddress($Criteria)) else () } </ns28:Customers> }; declare function tns:fixedCustomeraddress($CustomerGetCriteria as element(ns30:CustomerGetCriteria)) as element(ns28:Customer)*{ let $kCustomers := ns32:getCustomer( <ns33:KCustomerGetCriteria> { for $customerId in fn:distinct-values($CustomerGetCriteria/ns30:Customer/ns30:customerId) return <ns33:kId>{fn:data($customerId)}</ns33:kId> } </ns33:KCustomerGetCriteria> ) let $fAddresses := ns7:getAddress( <ns8:FAddressGetCriteria> { for $fId in fn:distinct-values($CustomerGetCriteria/ns30:Customer/ns30:fId) return <ns8:fId>{fn:data($fId)}</ns8:fId> } </ns8:FAddressGetCriteria> ) for $searchCustomer in $CustomerGetCriteria/ns30:Customer where $searchCustomer/ns30:customerIdType=fn:string("kId") return for $resultCustomer in $kCustomers/ns28:Customer where $searchCustomer/ns30:customerId = $resultCustomer/ns28:MetaInfo/ns28:customerId return <ns28:Customer> {$resultCustomer/ns28:MetaInfo} {$resultCustomer/ns28:Person} {$resultCustomer/ns28:Organization} {$fAddresses[ns29:MetaInfo/ns29:fId = $searchCustomer/ns30:fId]} </ns28:Customer> }; Expected input: <v1:CustomerGetCriteria xmlns:v1="http://customer.com"> <v1:Customer> <v1:customerId>654321</v1:customerId> <v1:customerIdType>kId</v1:customerIdType> <v1:fId>123456</v1:fId> </v1:Customer> <v1:Customer> <v1:customerId>654321</v1:customerId> <v1:customerIdType>kId</v1:customerIdType> <v1:fId>123456</v1:fId> </v1:Customer> <v1:returnAddress>true</v1:returnAddress> </v1:CustomerGetCriteria> Expected output: <t1:Customers xmlns:t1="http://customer.com"> <t1:Customer> <t1:MetaInfo> <t1:customerId>2336789</t1:customerId> <t1:customerIdType>kId</t1:customerIdType> </t1:MetaInfo> <t1:Person> <t1:lastName>lname</t1:lastName> <t1:firstName>fname</t1:firstName> <t1:birthDate>19990101</t1:birthDate> </t1:Person> <ns0:Address xmlns:ns0="http://address.com"> <ns0:MetaInfo> <ns0:fId>597892100</ns0:fId> <ns0:status>B</ns0:status> <ns0:addressType>PROPERTY_ADDRESS</ns0:addressType> </ns0:MetaInfo> </ns0:Property> </ns0:Address> </t1:Customer> </t1:Customers>
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






