Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SPARQL: combining variables with literals

Is it possible to create a subject in a SPARQL triple that is created by combining a variable and a literal?

My case is this:

OPTIONAL  
{
  $object dc:identifier $identifier .
  <info:fedora/abc:123/MODS> fedora-view:disseminationType $mods .
  <info:fedora/abc:123/TN> fedora-view:disseminationType $tn
}

$object looks like this: <info:fedora/abc:123> $identifier looks like this: abc:123 and what I need is this: <info:fedora/abc:123/MODS>

I can't use <info:fedora/$identifier/MODS> but is there another way to 'glue' variables and literals together?

like image 532
Danny_Joris Avatar asked Feb 14 '12 19:02

Danny_Joris


1 Answers

With SPARQL 1.1, you should be able to use a combination of BIND(), STR(), IRI(), and CONCAT() to do what you want. Something like:

SELECT * WHERE {
  $object dc:identifier $identifier .
  BIND(IRI(CONCAT(STR($object), "/MODS")) AS $new)
  $new fedora-view:disseminationType $mods .
  $new fedora-view:disseminationType $tn .
}
like image 87
Gregory Williams Avatar answered Sep 29 '22 09:09

Gregory Williams