Re: Formal Semantics: fs:convert-operand() erroneous?

Thanks for your quick reply, Michael, and for your clarification on my
example expression.

But I'm not sure, if my main point was actually understood: The formal
semantics function fs:convert-operand() is not sufficiently specified in
http://www.w3.org/TR/xquery-semantics/#sec_convert_operand.

The signature of the function allows the type `item*' for its first
argument, while the specification only describes the behavior for
`item?'. The example I gave (XMark 11) only triggered the problem. The
intention was probably to restrict the type of the first argument
(`$actual') to `item?'.

Regards,

Jens

On Mon, Aug 23, 2004 at 09:47:05AM -0700, Michael Rys wrote:

> Thanks for the comment. 
> 
> Let me address your comments about XMark 11's validity.
> 
> The static rules for numeric operations expect ?. So your expression
> below is a static error anyway.
> 
> You would have to write one of
> 
> (for $t in $i/text() return 5000 * $t)
> (5000 * exact-one($i/text())
> (5000 * zero-or-one($i/text())
> (5000 * ($i/text())[1]
> 
> Depending on what you want the behaviour to be.
> 
> HTH
> Michael
> 
> > -----Original Message-----
> > From: public-qt-comments-request@w3.org [mailto:public-qt-comments-
> > request@w3.org] On Behalf Of Jens Teubner
> > Sent: Monday, August 23, 2004 8:20 AM
> > To: public-qt-comments@w3.org
> > Subject: Formal Semantics: fs:convert-operand() erroneous?
> > 
> > 
> > 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
> > 
> 

-- 
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

Linus Torvalds is a lot like Bill Gates. Both are
about the same height.
                               -- USA Today

Received on Tuesday, 7 September 2004 13:27:38 UTC