grajkowski
grajkowski

Reputation: 369

SPARQL DBpedia - Retrieve Properties with numbers (DatatypeProperties, xsd)

So I encountered a Problem on DBpedia. Apparently I can retrieve any kind of property from a resource with the query below, but when the property is from the type DatatypeProperty or just a number (xsd:integer or something similar) the DBpedia SPARQL Endpoint returns an empty result.

I would like to know what I have to change or even better optional include in my current query to solve this problem.

Important note: Germany and population total are required inputs in my program. Please remember that I must use them.

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?objectLabel
WHERE {
      ?subject ?predicate ?object ; rdfs:label "Germany"@en . 
      ?predicate rdfs:label "population total"@en . 
      ?object rdfs:label ?objectLabel 
FILTER (LANG(?objectLabel)='en')
}

Thank you for your help.

Upvotes: 0

Views: 288

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

A DatatypeProperty is used to related an individual to a literal and literals can't have any outgoing edge, thus, no rdfs:label. If you want to have the lexical form of the literal you can use the str function:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT (str(?object) as ?value)
WHERE {
      ?subject ?predicate ?object ; rdfs:label "Germany"@en . 
      ?predicate rdfs:label "population total"@en
      FILTER (LANG(?objectLabel)='en')
}

Upvotes: 1

Related Questions