- From: Erik Bruchez <erik@bruchez.org>
- Date: Fri, 11 Sep 2015 10:15:17 -0700
- To: Nick Van den Bleeken <Nick.Van.den.Bleeken@inventivegroup.com>
- Cc: Forms WG <public-forms@w3.org>, "public-xformsusers@w3.org" <public-xformsusers@w3.org>
- Message-ID: <CAAc0PEVMawt1QeZk+E0gd45Tg0L_V38aShUushWynZ4AOUwHOQ@mail.gmail.com>
Nick, Are you suggesting choosing `xs:string?` as return type, instead of `xs:string`? Or `xs:date?` / `xs:dateTime?`. What we suggested in the last call was to leave the function signatures of `days-to-date` and `seconds-to-dateTime` alone (that is as they are in XForms 1.1), rather than trying to switch to `xs:date?` / `xs:dateTime?`. The issue with switching to `xs:date?` / `xs:dateTime?` is that backward compatibility is clearly broken. I assume below that the `days-to-date` function has an `xs:date?` return type. It's true that the following would be backward compatible: substring(days-to-date($nan), 1, 4) where `$nan` has the `number` or `xs:double` value `NaN`. (With both XForms 1.1/XPath 1.0 and XForms 2.0/XPath 2.0, the result is the empty string.) But the following would not be backward compatible: substring(days-to-date(11688), 1, 4) With XForms 2.0/XPath 2.0, Saxon for example reports: "Required item type of first argument of substring() is xs:string; supplied value has item type xs:date" So the tension between keeping things backward compatible vs. making them XPath 2.0-friendly remains. There doesn't seem to be a good middle ground. Since `days-to-date` and `seconds-to-dateTime` are not very XPath 2.0-like functions as far as date/time handling is concerned, we thought in the last call that it would be fine to keep their XForms 1.1 signature and kind of "park" these functions, leaving them mostly as backward-compatibility functions. For more date/time handling, new expressions would use standard XPath 2.0 functions (as awkward and unintuitive as they might be). If we really want to upgrade these two functions, we could maybe expose two different versions of these functions, depending on whether XPath 1.0 or XPath 2.0 is selected. What do you think? -Erik On Fri, Sep 11, 2015 at 6:15 AM, Nick Van den Bleeken < Nick.Van.den.Bleeken@inventivegroup.com> wrote: > Erik, > > Isn’t for the input parameter value of NaN returning an empty sequence not > quite close to an empty string? When the sequence is converted to a string > it will be an empty string. And in a lot of cases we convert to string in > XForms. There are of course cases where there will be a difference. But I > think that the advantages of returning an xs:date (or xs:dateTime) > overweigh the impact of the backwards incompatibility. > > Regards, > > Nick Van den Bleeken > > From: <ebruchez@gmail.com> on behalf of Erik Bruchez > Date: Wednesday 2 September 2015 06:49 > To: Public Forms, "public-xformsusers@w3.org" > Subject: ACTION-2029 - Check that integer promotes successfully to double > Resent-From: <public-xformsusers@w3.org> > Resent-Date: Wednesday 2 September 2015 06:50 > > All, > > This is the case AFAICT, for example, in XPath 2.0: > > fn:substring( > $sourceString as xs:string?, > $startingLoc as xs:double > ) as xs:string > > fn:substring( > $sourceString as xs:string?, > $startingLoc as xs:double, > $length as xs:double > ) as xs:string > > I assume that, for compatibility with XPath 1.0, these functions take > `xs:double` parameters. I checked that, with Saxon at least, passing an > `xs:integer` works, as we had suspected was the case based on the spec, > namely: > > - you can pass an `xs:decimal` to an `xs:double`, possibly with loss of > precision > - `xs:integer` is a subtype of `xs:decimal` > - therefore you can pass an `xs:integer` to an `xs:double` > > This means that the following XForms functions can take `xs:double`: > > - `days-to-date()` [1] > - `seconds-to-dateTime()` [2] > > and so I fixed the types in the spec: > > > https://www.w3.org/MarkUp/Forms/wiki/index.php?title=XPath_Expressions_Module&diff=4211&oldid=4209 > > Doing so, I have found another issue in these two functions, namely the > following language from XForms 1.1: > > > An input parameter value of NaN results in output of the empty string. > > With the change to `xs:double`, the function parameters are now > backward-compatible. But the return types are not: in XForms 1.1, they were > `string`, and here they are `xs:date` or `xs:dateTime`. > > We can either: > > 1. Change back the return types to `xs:string`, which is compatible with > XForms 1.1, but not XPath 2.0-friendly, > 2. or use `xs:date?` and `xs:dateTime?` return types. A `NaN` parameter > returns the empty sequence. > > -Erik > > [1] > https://www.w3.org/MarkUp/Forms/wiki/XPath_Expressions_Module#The_days-to-date.28.29_Function > > [2] > https://www.w3.org/MarkUp/Forms/wiki/XPath_Expressions_Module#The_seconds-to-dateTime.28.29_Function >
Received on Friday, 11 September 2015 17:16:06 UTC