- From: Jens Teubner <Jens.Teubner@uni-konstanz.de>
- Date: Mon, 23 Aug 2004 17:19:51 +0200
- To: public-qt-comments@w3.org
Hi, the latest XQuery Formal Semantics defines the fs:convert-operand() function in Section 6.1.3 [1]. In a nutshell, fs:convert-operand() casts its first argument to the type of a given sencond argument, if it had been a subtype of xdt:untypedAtomic before. Otherwise the first argument is returned unchanged. The type of fs:convert-operand(), however, is defined as fs:convert-operand($actual as item *, $expected as xdt:anyAtomicType) as xdt:anyAtomicType ? . Note that it allows an arbitrarily long sequence of items as its first argument. The return value, however, is a sequence of at most length one. The specifications only consider the case where $actual has a length no longer than one. So the return value for $actual being a longer sequence remains undefined. fs:convert-operand() could easily be fixed by restricting $actual to an optional item (item?). This, however, would make queries such as XMark 11 [2] illegal: for $p in fn:doc("auction.xml")/site/people/person return let $l := for $i in document("auction.xml")/site/open_auctions/open_auction/initial where $p/profile/@income > (5000 * $i/text()) return $i return element items { attribute name { $p/name/text() } text { count ($l) } } Note the `5000 * $i/text()'. $i/text() evaluates to node*. The Formal Semantics rule for Arithmetics [3] applies fn:data(), returning an xdt:untypedAtomic* on the non-validated document. If the first argument of fs:convert-operand() were restricted to item? it could not be applied to `$i/text()', making the above query illegal. Regards Jens Teubner [1] http://www.w3.org/TR/xquery-semantics/#sec_convert_operand [2] http://www.ins.cwi.nl/projects/xmark/Assets/xmlquery.txt [3] http://www.w3.org/TR/xquery-semantics/#sec_arithmetic -- Jens Teubner University of Konstanz, Department of Computer and Information Science D-78457 Konstanz, Germany Tel: +49 7531 88-4379 Fax: +49 7531 88-3577 http://www.inf.uni-konstanz.de/~teubner Statistics show that most people are in the majority, while a few are in the minority. -- Nitin Borwankar
Received on Monday, 23 August 2004 15:22:23 UTC