sparql - bind doesn't seem to be working on all items -
this minimum data
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix owl: <http://www.w3.org/2002/07/owl#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/xmlschema#> prefix rs: <http://www.semanticrecommender.com/rs#> prefix mo: <http://www.musicontology.com/mo#> prefix : <http://www.musicsemanticontology.com/mso#> mo:5th_symphony_for_beethoven mo:germansymphony . mo:nabucco_overture mo:operaoverture . rs:operaweek2016 rs:temporalcontext ; rs:appliedonitems mo:operaoverture . rs:symphonyfestival2016 rs:temporalcontext ; rs:appliedonitems mo:germansymphony .
this query
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix owl: <http://www.w3.org/2002/07/owl#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/xmlschema#> prefix rs: <http://www.semanticrecommender.com/rs#> prefix mo: <http://www.musicontology.com/mo#> prefix : <http://www.musicsemanticontology.com/mso#> select distinct ?item ?temporalcontextweight ?temporalcontext ?itemclasstemporal { { values (?item) {(mo:new_world_symphony)(mo:nabucco_overture)(mo:5th_symphony_for_beethoven )} } optional { ?temporalcontext rdf:type rs:temporalcontext ; rs:appliedonitems ?itemclasstemporal . ?item rdf:type ?itemclasstemporal values ?temporalweight {100000} } values ?defaultnotemporalcontext2 { 1 } bind(if(bound(?temporalweight), ?temporalweight, ?defaultnotemporalcontext2) ?temporalcontextweight) }
this result
as see, there 1 row each item, however, there should 2 rows, because have two instances of rs:temporalcontext
class, , if item
not class ?itemclasstemporal
, there bind bind default value
this replication of problem, real query , real data complex
update
after first answer can see reason why binding not working, however, updated question bellow , still binding or else not working
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix owl: <http://www.w3.org/2002/07/owl#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/xmlschema#> prefix rs: <http://www.semanticrecommender.com/rs#> prefix mo: <http://www.musicontology.com/mo#> prefix : <http://www.musicsemanticontology.com/mso#> select distinct ?item ?temporalcontextweight ?temporalcontext ?itemclasstemporal { { values (?item) {(mo:new_world_symphony)(mo:nabucco_overture)(mo:5th_symphony_for_beethoven )} } optional { ?temporalcontext rdf:type rs:temporalcontext ; rs:appliedonitems ?itemclasstemporal . optional{#new ?item rdf:type ?itemclasstemporal values ?temporalweight2 {100000} }#new bind(if (bound(?temporalweight2), ?temporalweight2, 1) ?temporalweight) } values ?defaultnotemporalcontext2 { 1 } bind(if(bound(?temporalweight), ?temporalweight, ?defaultnotemporalcontext2) ?temporalcontextweight) }
look there optiona of trible ?item ?itemclasstemporal
mo:new_world_symphony
=> no optional match => 1 row.
simplifying:
select * { ?temporalcontext rs:appliedonitems ?itemclasstemporal . ?item rdf:type ?itemclasstemporal }
has 1 match each ?item.
for specific ?temporalcontext
there 1 rdf:type rs:temporalcontext
.
Comments
Post a Comment