简体   繁体   中英

Yasgui SPARQL Query search for FOAF name doesn't work

I am using the Jamendo Yasgui SPARQL query to search for artist names. It works like this:

 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;} 

If I want to find a specific name like below, it does not work. Why?

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";}

The data exists as you can see in the RDF/XML:

<foaf:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Carton</foaf:name>

Because SPARQL syntax was built to look like Turtle syntax (and vice versa), it's often helpful to look at your data in Turtle when building SPARQL queries. This 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>

-- says the same thing as this Turtle --

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 .

-- so your SPARQL query must be (modulo whitespaces, each of which may be reduced to a single space) --

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 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM