[Mulgara-general] Substring Function in Sparql?

Paul Gearon gearon at ieee.org
Fri Aug 21 22:29:39 UTC 2009


On Fri, Aug 21, 2009 at 2:14 PM, Stone Xiang<stone.xiang at yahoo.com> wrote:
> The scenario is a (not so elegant) extension of the Fedora repository, where
> the objects
> in the RELS-EXT datastream are used to store some data values. A more
> appropriate
> example would be:
> SELECT $s from <#ri> {$s <some predicate> $t}
> order by substring($t, 5, 3)
> Here the subject of <some predicate> is the URI of a Fedora item while the
> object stores
> several fields of data and one of them is relevant to sorting (or other
> filtering
> operations).
> Since you already said there is no substring fuctino in Sparql, I think I'll
> find some other
> way around.

Not in standard SPARQL, but I'm sure that some implementation will
have this function available. I've been looking to add extra functions
myself (it's VERY easy). I'd offer to do it here right now, only I
haven't implemented ORDER BY for arbitrary expressions yet. You'd have
to set a variable. So it would probably end up as:

  SELECT $s from <#ri>
  WHERE {$s <some predicate> $t . LET ($ord := fn:substring($t, 5, 3)}
  ORDER BY $ord

Regards,
Paul



More information about the Mulgara-general mailing list