Scaraffe
Scaraffe

Reputation: 5241

SPARQL queries with blank-nodes as subjects

I have data like this:

<http://wikidata.dbpedia.org/resource/Q1000019>  <http://purl.org/voc/vrank#hasRank>
                                 [<http://purl.org/voc/vrank#rankValue> "0.15"^^xsd:float] .
<http://wikidata.dbpedia.org/resource/Q100004>   <http://purl.org/voc/vrank#hasRank>
                                 [<http://purl.org/voc/vrank#rankValue> "0.15"^^xsd:float] .
<http://wikidata.dbpedia.org/resource/Q1000047>  <http://purl.org/voc/vrank#hasRank>
                                 [<http://purl.org/voc/vrank#rankValue> "0.15"^^xsd:float] .

And I am trying a query like this:

SELECT ?c WHERE {?s <http://purl.org/voc/vrank#hasRank> ?c}

This just returns a blank node. How do get the value 0.15 which is between quotes here?

Upvotes: 0

Views: 1268

Answers (2)

Alper t. Turker
Alper t. Turker

Reputation: 35229

DESCRIBE ?c
where {?s <http://wikidata.dbpedia.org/resource/Q1000047> <http://purl.org/voc/vrank#hasRank> ?c}

This will give you all info about your BN (?c)

Upvotes: 1

user205512
user205512

Reputation: 8888

You can just lift the pattern you can see in the data (reformatted a little):

SELECT ?c 
WHERE 
{ 
    ?s <http://purl.org/voc/vrank#hasRank> [ 
        <http://purl.org/voc/vrank#rankValue> ?c 
    ]
}

To explain, [ ... content ... ] is a convenience in turtle and sparql to introduce a bnode (typically in an object position) and add some properties of that bnode.

Upvotes: 1

Related Questions