Yeah, I discussed the XPath function step in my earlier response, and Hans-Juergen mentioned it to, below.
But if order matters, beware. The XPath function step alternative may not evaluate in the same order as the nodes being selected by the XPath. I've been bit by that a few times. On Jan 10, 2012, at 9:51 PM, David Lee wrote: > Alternative 3 > > $order/coupon-code/looup-coupon-code(.) > > > Sent from my iPad (excuse the terseness) > David A Lee > d...@calldei.com > > > On Jan 10, 2012, at 1:29 PM, Hans-Juergen Rennau <hren...@yahoo.de> wrote: > >> Hi Ron, >> >> thank you very much for illustrating the potential usefulness of function >> mapping! >> >> Certainly this is a matter of personal taste, but just this remark: although >> the use of function mapping makes the code especially compact, I definitely >> prefer the FLWOR alternative (or the function step alternative), which makes >> looping explicit and thus avoids the risks of unintended looping and (worse) >> of unintended omission of processing. I think the code is safer and, yes, >> cleaner, if one remembers that function mapping depends on the repective >> parameter to be declared as a single item sequence type, which means that >> the function invocation cannot be recognized to be a mapping invocation: the >> parts producing the looping are separate, one being the invocation, one >> being the signature. I regard this as a kind of obscurity better to be >> avoided. >> >> And the difference in code length is minimal: >> >> alternative #1 (function mapping) >> lookup-coupon-code ($order/coupon-code) >> >> alternative #2 (FLWOR) >> for $c in $order/coupon-code return looup-coupon-code($c) >> >> Hans-Juergen >> >> Ron wrote: >> "Function mapping can actually be very handy, you >> shouldn't just automatically turn it off and forget >> about it." >> >> _______________________________________________ >> General mailing list >> General@developer.marklogic.com >> http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general --- Ron Hitchens {mailto:r...@ronsoft.com} Ronsoft Technologies +44 7879 358 212 (voice) http://www.ronsoft.com +1 707 924 3878 (fax) Bit Twiddling At Its Finest "No amount of belief establishes any fact." -Unknown _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general