W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2005

Re: casting support

From: Dave Beckett <dave.beckett@bristol.ac.uk>
Date: Mon, 6 Jun 2005 15:25:49 +0100
To: Eric Prud'hommeaux <eric@w3.org>
Cc: RDF Data Access Working Group <public-rdf-dawg@w3.org>
Message-ID: <20050606152549.6b07bbf0@hoth.ilrt.bris.ac.uk>

On Mon, 6 Jun 2005 00:52:47 -0400, Eric Prud'hommeaux <eric@w3.org> wrote:

> On Wed, Jun 01, 2005 at 11:01:40AM +0100, Dave Beckett wrote:
> > > > So, I'd like a new operator CAST
> > > >   CAST(URI u, Unicode string s) returning what would be written as s^^u


> I think the only functionality we get out of casting a binding to a
> type with no defined support is the ability to compare it to another
> binding of the same type. (If there is library support for this alien
> type, then the query will only be useful on certain systems, and the
> lack of interop on the query will make interop of casting moot.) Any
> comparisons on an alien type will be strictly lexical; the same
> functionality comes of casting both to str before comparing them.
> Can you think of a query that will be interoperable if cast were added
> to the language that you can't do with casting to string? 


I had a look what XQuery says on casting

  [[The name of a constructor function is the same as the name of the
  [XML Schema Part 2: Datatypes Second Edition] built-in type (see
  5.1 Constructor Functions for XML Schema Built-in Types) or
  user-derived type (see 5.3 Constructor Functions for User-Defined
  Types) that is the target for the conversion, and the semantics are
  exactly the same as for a cast expression; for example,"
  xs:date("2003-01-01") " means exactly the same as " "2003-01-01"
  cast as xs:date? ".]]
  -- http://www.w3.org/TR/xpath-functions/#casting

However what I was thinking of was the second case, user defined
which is in 5.3:

  [[For every atomic type in the static context (See Section 2.1.1
  Static ContextXP) that is derived from a primitive type, there is a
  constructor function (whose name is the same as the name of the
  type) whose effect is to create a value of that type from the
  supplied argument. ...]

  -- http://www.w3.org/TR/xpath-functions/#constructor-functions-for-user-defined-types

I think the crucial different from SPARQL is that XQuery allows
declarations of types, so you can tell when you have a user-defined
one versus a built-in one.  Since SPARQL doesn't, having casting for
user datatypes is not so useful.

So given there was no other interest in CAST, I withdraw the

I note though, that XQuery does say that the constructor functions
are named the same as the built-in type.  We should make that note in
SPARQL too.  Calling them constructor functions and refering to the
XQuery section would be good also.  The words in SPARQL Query
Table 11.2 at http://www.w3.org/TR/2005/WD-rdf-sparql-query-20050217/#tests
don't mention this and it's not quite so clear in section 11.1 either.

Received on Monday, 6 June 2005 14:31:20 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:00:47 UTC