W3C home > Mailing lists > Public > public-forms@w3.org > April 2015

ACTION-2018 - Confirm that min() and max() are compatible with the ones in xpath 2

From: Erik Bruchez <erik@bruchez.org>
Date: Tue, 31 Mar 2015 22:52:22 -0700
Message-ID: <CAAc0PEVrzG2C3v3mK-a66TB2wVXaJUL1_zmhQEYmyym8rvG6gA@mail.gmail.com>
To: Forms WG <public-forms@w3.org>, "public-xformsusers@w3.org" <public-xformsusers@w3.org>
All,

This action item is about the min/max functions. The current status is
as follows:

- XForms 1.1 defines min/max functions in an XPath 1.0 context.
- XPath 2.0 defines standard min/max functions.
- XForms 2.0 takes the XForms 1.0 functions and kind of adapts them to
XPath 2.0.

I think that it comes down to this:

1. Either XForms 2.0 *doesn't* define the min/max functions anymore
(or only in the context of XPath 1.0 compatibility), and delegates
this to XPath 2.0.
2. Or XForms 2.0 defines its own min/max functions *in addition* to
the XPath 2.0 ones, maybe only in the xf: namespace.

Either way, the XPath 2.0 functions should be available in the default
namespace.

The XForms 1.1 functions have the following signature:

    number min(node-set)
    number max(node-set)

With the rule "If the parameter is an empty node-set, or if any of the
nodes evaluate to NaN, the return value is NaN.".

The XPath 2.0 functions work slightly differently:

- They don't return NaN, except if one of the value passed is NaN.
- Instead they raise a type error if a value cannot be converted to a
number (by default, `xs:double`).

So with the following, assuming untyped element nodes:

    <value>42</value>
    <value>foo</value>

and the expression:

    min(//value)

The XForms 1.1 functions returns NaN, but the XPath 2.0 functions
raise a type error.

In addition, the XPath 2.0 functions can deal with other types, such
as `xs:integer`, `xs:decimal`, etc. For example:

    min((xs:integer("42"), xs:decimal("1.2")))

returns a value of type `xs:decimal`. Any comparable type is
supported, even `xs:string`:

    min(("a", "b"))

In practice, I think the main compatibility issue arises with
`xs:double`, which would probably be the most common case when
migrating a form from XForms 1.0/XPath 1.0 to XForms 2.0/XPath 2.0.

I am not absolutely sure if the incompatibilities warrant having two
sets of functions, because that would be quite confusing!

-Erik
Received on Wednesday, 1 April 2015 05:53:10 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 1 April 2015 05:53:10 UTC