Search code examples
rdfsparql

SPARQL query is NULL by triples are visible


I'm using the data at http://agris.fao.org/aos/records/US19970166596, and sending it this query, but I get a null set of results:

PREFIX dc: <http://purl.org/dc/terms/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
SELECT ?identifier ?title ?abstract
FROM NAMED <http://agris.fao.org/aos/records/US19970166596>
WHERE {
  ?identifier dc:identifier ?Identifier .
  ?title dc:title ?Title .
  ?abstract bibo:abstract ?Abstract .
}

SPARQL results

It occurred to me that SPARQL might not see this page as a graph. So I checked it using the Rhizomik service, to get these results. Rhizomik properly processes the URI and generates RDFa. Also you can see information that is not exposed on the source page. Example: j.3:creator where a class is foaf:Person and a property is foaf:name.

Does the SPARQL query need to use, for example, j.3:creator rather than dc:creator?

How can I extract the value of the term foaf:name? Should I declare the prefix foaf and then query for a value (e.g. Finley J.W.)? Should I use an alternate method to process the content of the URI?


Solution

  • FROM NAMED creates a name graph (access with GRAPH in the query).

    FROM loads the default graph, which is what you are querying.

    Remove NAMED

    PREFIX dc: <http://purl.org/dc/terms/>
    PREFIX bibo: <http://purl.org/ontology/bibo/>
    SELECT ?identifier ?title ?abstract
    FROM  <http://agris.fao.org/aos/records/US19970166596>
    WHERE {
      ?identifier dc:identifier ?Identifier .
      ?title dc:title ?Title .
      ?abstract bibo:abstract ?Abstract .
    }
    

    and it works for me.