The query you requested will only select objects with foaf:homepage and Harvard University does not. (That is, the resource does not have the foaf:homepage property. Obviously, the university has a homepage.) UMass Boston does not match an additional template -
OPTIONAL {?s geo:lat ?lat ; geo:long ?long . ?sd:endowment ?endowment . }
- because this pattern matches only when ?s has geo:lat , a geo:long and a d:endowment . Although the template is optional, the entire template must either match or not; you do not get partial matches.
Here's your query, redesigned to use the built-in namespaces that the DBPedia SPARQL endpoint currently supports (this list can be modified over time), with the OPTIONAL parts broken up as needed and moved to the end. (Moving them all the way to the end is just an aesthetic consideration.) I tried some different limitations, and itβs interesting to note that only 32 universities have dbpprop:country "US"@en , but 273 have dbpprop:country "United States"@en . A total of 7620 results were obtained.
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpprop: <http://dbpedia.org/property/> SELECT ?label ?homepage ?lat ?long ?endowment WHERE { ?school a <http://schema.org/CollegeOrUniversity> { ?school dbpedia-owl:country dbpedia:United_States } UNION { ?school dbpprop:country dbpedia:United_States } UNION { ?school dbpprop:country "US"@en } UNION { ?school dbpprop:country "United States"@en } OPTIONAL { ?school rdfs:label ?label . FILTER (LANGMATCHES(LANG(?label), 'en')) } OPTIONAL { ?school foaf:homepage ?homepage } OPTIONAL { ?school geo:lat ?lat ; geo:long ?long } OPTIONAL { ?school dbpedia-owl:endowment ?endowment } }
SPARQL Results
source share