Blank nodes vs variables in SPARQL queries

38 Views Asked by At

These two SPARQL queries result in different returns in this SPARQL endpoint (Swedish libraries). Why? I expected them to be functionally equivalent.

Query 1

PREFIX : <https://id.kb.se/vocab/>

SELECT DISTINCT ?language ?langName {
   [] :contribution [ a :PrimaryContribution ;
           :role rel:author ;
           :agent <https://libris.kb.se/qn247n18248vs58#it> ] ;
       :translationOf/a :Work ;
       :language ?language .
   ?language :prefLabel ?langName .

   FILTER(lang(?langName) = 'sv')    
}

Query 2

PREFIX : <https://id.kb.se/vocab/>

SELECT DISTINCT ?language ?langName {
   ?endeavor :contribution ?c .
   ?c a :PrimaryContribution ;
           :role rel:author ;
           :agent <https://libris.kb.se/qn247n18248vs58#it>.
   ?endeavor  :translationOf ?t .
   ?t a :Work ;
         :language ?language .
   ?language :prefLabel ?langName .

   FILTER(lang(?langName) = 'sv')    
}

My understanding of 4.14 Blank node is that blank nodes in queries act as variables. I've read this StackOverflow question, and I know that two blank nodes in a SPARQL query need not reference the same node, but I do not think that is relevant in this case. Do you have any thoughts on the matter?

1

There are 1 best solutions below

0
AndyS On

The first has:

[] :translationOf/a :Work ;
   :language ?language .

The second has:

?endeavor  :translationOf ?t .
?t a :Work ;
   :language ?language .

The :language part is on different subject variables.

It is [] (corresponds to ?endeavor in the second) in the first query and the object of :translationOf in the second.