我正在使用Jamendo Yasgui SPARQL查询来搜索艺术家姓名。它是这样的:
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {?a a mo:MusicArtist ;foaf:name ?name;}
如果我想找到一个如下所示的特定名称,则它不起作用。为什么?
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {?a a mo:MusicArtist ;foaf:name "Carton";}
数据存在,如您在RDF / XML中所见:
<foaf:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Carton</foaf:name>
答案 0 :(得分:1)
由于SPARQL语法的构建看起来像Turtle语法(反之亦然),所以在构建SPARQL查询时在Turtle中查看数据通常会很有帮助。此RDF / XML-
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE rdf:RDF><rdf:RDF xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:ns1="http://purl.org/ontology/mo/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<ns1:MusicArtist rdf:about="http://dbtune.org/jamendo/artist/5655">
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
<owl:sameAs rdf:resource="http://zitgist.com/music/artist/b8b40a3c-91c0-413b-a4f9-194ef0c7151a"/>
<foaf:based_near rdf:resource="http://sws.geonames.org/2802361/"/>
<foaf:homepage rdf:resource="http://cartonpate.com"/>
<foaf:img rdf:resource="http://img.jamendo.com/artists/c/carton.jpg"/>
<foaf:made rdf:resource="http://dbtune.org/jamendo/record/4957"/>
<foaf:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Carton</foaf:name>
</ns1:MusicArtist>
</rdf:RDF>
-与这只海龟说同样的话-
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
PREFIX owl: <http://www.w3.org/2002/07/owl#> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/> .
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://dbtune.org/jamendo/artist/5655>
a <http://purl.org/ontology/mo/MusicArtist>,
rdfs:Resource ;
owl:sameAs <http://zitgist.com/music/artist/b8b40a3c-91c0-413b-a4f9-194ef0c7151a> ;
foaf:based_near <http://sws.geonames.org/2802361/> ;
foaf:homepage <http://cartonpate.com> ;
foaf:img <http://img.jamendo.com/artists/c/carton.jpg> ;
foaf:made <http://dbtune.org/jamendo/record/4957> ;
foaf:name "Carton"^^xsd:string .
-因此您的SPARQL查询必须是(模数空格,每个空格都可以减少到一个空格)-
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT * WHERE { ?a a mo:MusicArtist ;
foaf:name "Carton"^^xsd:string }