我正在尝试使用 SPARQL 获取大学的名称:
rdf 数据如下(还有更多,但这无关紧要)。
<Organization rdf:about="http://data.semanticweb.org/organization/the-university-of-queensland">
<rdfs:label>The University of Queensland</rdfs:label>
<homepage rdf:resource="http://www.uq.edu.au/"/>
<member rdf:resource="http://data.semanticweb.org/person/jane-hunter"/>
<member rdf:resource="http://data.semanticweb.org/person/kwok-cheung"/>
<member rdf:resource="http://data.semanticweb.org/person/robert-m-colomb"/>
<name>The University of Queensland</name>
</Organization>
我写了一个查询数据的java程序。我查询数据的字符串如下:
queryString += "PREFIX swrc: <http://swrc.ontoware.org/ontology#> \n";
queryString += "PREFIX dc: <http://purl.org/dc/elements/1.1/> \n";
queryString += "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n";
queryString += "PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> \n";
queryString += "PREFIX ical: <http://www.w3.org/2002/12/cal/ical#> \n";
queryString += "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n";
queryString += "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n";
queryString += "PREFIX swc: <http://data.semanticweb.org/ns/swc/ontology#> \n";
queryString += "PREFIX swrc_ext: <http://www.cs.vu.nl/~mcaklein/onto/swrc_ext/2005/05#> \n";
queryString += "SELECT ?name WHERE {\n";
queryString += "?university rdfs:label ?aff . \n ?university foaf:name ?name FILTER(str(?aff)='uni') }";
不幸的是,这是不正确的,因为没有返回结果:
<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='w3.org/2005/sparql-results#'>
<head>
<variable name='name'/>
</head>
<results>
</results>
</sparql>
谁能指出我正确的方向?
PS 如果可能的话,我只想获取 10 个大学名称。