5

I am trying to fill the empty spaces generated by the use of Optional in the SPARQL query language. Are there any ways that I can achieve this?

The use of !bound on the optional variable generates true or false, but I want to fill the cells with my own values such as "?" or "unknown".

w5m
  • 2,286
  • 3
  • 34
  • 46
  • Please can you show the code you're using currently. – w5m Nov 01 '13 at 09:26
  • Select ?a ?b ?c Where ?a1 rdfs:type hvs:whi; rdfs:label ?a ?a2 rdfs:type hvs:whi; rdfs:label ?a Optional ?s1 rdf:type hvs:whi; rdfs:label ?b . ?m hvs:wmm ?a; hvs:into ?s1; hvs:will ?c . Filer (?c =1 ll ?c = 2 ll (!bound (?c) = 'unknown') Issue: the resultset has some ?c without values (empty cells). I want to replace these cells with 'unknown'. Sorry that i cound not follow strickly the syntax of sparql with respect to curves. I am using my phone to type. Regards – honour nwagwu Nov 01 '13 at 12:04

1 Answers1

8

Perhaps you could use one of the following constructs...

COALESCE(?c, "unknown")

Source: http://www.w3.org/TR/sparql11-query/#func-coalesce

or

IF(bound(?c), ?c, "unknown")

Source: http://www.w3.org/TR/sparql11-query/#func-if

w5m
  • 2,286
  • 3
  • 34
  • 46