Feature:Typed literal constructor

From SPARQL Working Group
Jump to: navigation, search

[ [ Category:Features ] ]

Feature: Typed literal constructor

An operator, such as X^^Y, should return a literal whose string value is equal to string value of X and type is equal to IRI value of Y.

Feature description

If CONSTRUCT supports expressions in construction patterns then it should be possible to create literals of all sorts. X^^Y can be convenient in FILTERs as well, but FILTER (SAMETERM(X^^Y,Z)) can be replaced with FILTER (isLITERAL (Z) and (STR(X)=STR(Y)) and (DATATYPE(X)=DATATYPE(Y)) whereas CONSTRUCT makes the feature next to unavoidable.

Two semantics are possible for X ^^ unbound, if X is typed literal. It may either return untyped variant of X ("remove the type") or return X as is ("no type -- nothing to do"). Two semantics are also possible if X is a literal with language or a node. Assuming that X ^^ Y tends to work like str(X) ^^ Y, it may either return X as is ("no type -- nothing to do") or work like str(X) ^^ unbound. Thus if we should choose the simplest possible semantics, we can make rule "X ^^ unbound returns X" unconditional and of highest priority.

Example

CONSTRUCT { 
  ?ferment <agent>
      `(?protein-sequence-string ^^ ?serialization-type )`
  } ...

Existing Implementation(s)

Virtuoso will support that as soon as syntax of the feature is confirmed by a draft of the spec.

Existing Specification / Documentation

List any existing text that attempts a formal definition of this extension. This could be a draft specification, API or syntax documentation, etc.

Compatibility

In order to ensure the compatibility, the ^^ operator should have the priority one less than unary minus, so -5^^<mm> and - (space) 5 ^^ <mm> should both result in "-5"^^<mm>, not a value in former and unary minus operator applied to "5"@<mm> in the latter case.

For biggest possible compatibility, a new built-in function can be introduced, not an operator. Nevertheless, there should be something.

Links to postponed Issues

Has this extension/use case some history in the group already? I.e. are there posponed issues or archived mail-threads related to this originating from DAWG?

Related Features

Champions

  • OpenLink

Use cases

A description of one or more use cases, the solution of which requires this feature. Multiple use cases can be added to each feature.

References