RE: Casting: Use Cases VS Specs

Steve, the "for in return" is basically a map (just not using functional
syntax).

Since Xquery currently does not provide such higher-order functions for
a variety of reasons, I personally don't think adding them at this stage
would be a good idea. But I agree that such higher-order functions
should be more closely investigated in a version 2.

Best regards
Michael

> -----Original Message-----
> From: Steve Sullivan [mailto:sullivan@Mathcom.COM] 
> Sent: Friday, March 08, 2002 11:09 AM
> To: Ashok Malhotra
> Cc: sullivan@Mathcom.COM; www-ql@w3.org
> Subject: RE: Casting: Use Cases VS Specs
> 
> 
> Hi Ashok,
> 
> Thanks for your reply.  But wouldn't we still have to handle 
> the sequence explicitly, like:
>  old: min( decimal($p/text()))
>  new: min( for $v in $p/text() return decimal($v))
> 
> Maybe what we need is a handful of mapping operators 
> (functionals), as in many functional languages.
> 
> So   "map( decimal, $p/text())"  would map the decimal function
> over the sequence  $p/text().
> 
> Cheers,
> Steve
> 
> Ashok Malhotra writes:
>  > Steve:
>  > There is an open issue on whether we allow constructors to 
> take  > expressions as arguments.  If we decide that we do, 
> then the use case  > would work fine.  > Otherwise it would 
> have to be changed to "cast as decimal($p/text())".  > 
>  > Please note that the documents you are looking at are 
> works in process  > and are likely to change.  Even though 
> the editors make their best  > efforts the specs will 
> sometimes have inconsistencies.  Our apologies.  > 
>  > 
>  > All the best, Ashok 
>  > ===========================================================
>  > Ashok Malhotra              <mailto: ashokma@microsoft.com> 
>  > Microsoft Corporation
>  > 212 Hessian Hills Road
>  > Croton-On-Hudson, NY 10520 USA 
>  > Redmond: 425-703-9462                New York: 914-271-6477 
>  > 
>  > 
>  > 
>  > -----Original Message-----
>  > From: Steve Sullivan [mailto:sullivan@Mathcom.COM] 
>  > Sent: Friday, March 08, 2002 9:28 AM
>  > To: www-ql@w3.org
>  > Subject: Casting: Use Cases VS Specs
>  > 
>  > 
>  > Hi,
>  > 
>  > There appears to be a mismatch between the XML Query Use 
> Cases  > and the Functions and Operators specs.  > 
>  > In the XML Query Use Cases W3C Working Draft 20 December 
> 2001,  > section 1.1.9.10 Q10, the example is:
>  >     <results>
>  >     {
>  >         let $doc := document("prices.xml")
>  >         for $t in distinct-values($doc//book/title)
>  >         let $p := $doc//book[title = $t]/price
>  >         return
>  >           <minprice title={ $t/text() }>
>  >     <price>{ min(decimal($p/text())) }</price>
>  >     </minprice>
>  >     }
>  >     </results>
>  > 
>  > The expression "min(decimal($p/text()))" implies that the
>  > cast decimal() can be applied to a sequence.
>  > 
>  > Yet nowhere in "XQuery 1.0 and XPath 2.0 Functions and 
> Operators  > W3C Working Draft 20 December 2001" is there 
> such as cast.  > 
>  > Section 3.2.1 discusses a decimal() constructor that takes
>  > a single string literal.
>  > Section 14 discusses casting functions from primitives to 
> primitives,  > but not over sequences.  > 
>  > The intent of the use case is clear ... apparently the 
> cast  > should be applied to each element of the sequence.  > 
> But where is it in the specs?  > 
>  > Thanks,
>  > 
>  > Steve
>  > 
>  > 
>  > ========================================
>  > Steve Sullivan    sullivan@mathcom.com
>  > 
>  >    Mathcom Solutions: Custom Software Development.
>  >     * XML, XQuery, XSLT, Java, JDBC, J2EE, JSP, JNI, ...
>  >     * Mathematical optimization, simulation, and modeling.
>  > 
>  > http://www.mathcom.com    303-494-7115
>  > ========================================
> 
> -- 
> 
> ========================================
> Steve Sullivan    sullivan@mathcom.com
> 
>    Mathcom Solutions: Custom Software Development.
>     * XML, XQuery, XSLT, Java, JDBC, J2EE, JSP, JNI, ...
>     * Mathematical optimization, simulation, and modeling.
> 
http://www.mathcom.com    303-494-7115
========================================

Received on Friday, 8 March 2002 14:51:53 UTC