W3C home > Mailing lists > Public > public-xformsusers@w3.org > September 2015

ACTION-2029 - Check that integer promotes successfully to double

From: Erik Bruchez <erik@bruchez.org>
Date: Tue, 1 Sep 2015 21:49:21 -0700
Message-ID: <CAAc0PEXeQfhZaGoV8xNiCwQ35+Rcok5p_nRd40BzjJSRYefkzg@mail.gmail.com>
To: Forms WG <public-forms@w3.org>, "public-xformsusers@w3.org" <public-xformsusers@w3.org>
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 Wednesday, 2 September 2015 04:50:11 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 2 September 2015 04:50:11 UTC