简体   繁体   中英

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?

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 .
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM