[Mulgara-general] TQL: how to cast literal as URI

Paul Gearon gearon at ieee.org
Mon Jul 27 16:53:00 UTC 2009


On Mon, Jul 27, 2009 at 11:30 AM, Dragisa
Krsmanovic<dkrsmanovic at plos.org> wrote:
> <info:doi/10.1371/123> <dc:creator>  'info:doi/10.1371/abc'
> <info:doi/10.1371/abc> <foaf:name> 'John Doe'
>
> If I have these two triplets how would I write the query to find creator
> of <info:doi/10.1371/123> ? I need a way to cast a string to url.

You need SPARQL, since TQL doesn't do it. The literal and the URI are
completely different things internally, and only SPARQL exposes the
operation to convert them.

PREFIX dc: <http://purl.org/dc/elements/1.1/>

SELECT $a $b
WHERE {
  $a dc:creator $lit .
  $uri foaf:name $b
  FILTER ($lit = str($uri))
}

There is a way to do it on a join, without using a filter, but it
requires variable assignment, which won't be available until the next
release (and while something similar will be in the final form of
SPARQL, I don't think it will allow for this), so I haven't mentioned
it here.

If you really, absolutely need this in TQL, then let me know, and I'll
consider it. But it won't be too soon.

Regards,
Paul



More information about the Mulgara-general mailing list