I have the following data set in my fuseki server:
<http://person/Mark-John> <http://purl.org/dc/elements/1.1/name>
"Mark John" ;
<http://purl.org/dc/elements/1.1/nationality>
"American" .
<http://person/Elizabeth-Mary>
<http://purl.org/dc/elements/1.1/name>
"Elizabeth Mary" ;
<http://purl.org/dc/elements/1.1/nationality>
"American" .
How can I get the data only for the entry that has name
= "Mark John" ?
This is what I've tried:
public static void main(String[] argv) throws IOException {
execSelectAndPrint(
"http://localhost:3030/Date/query",
"PREFIX dc: <http://purl.org/dc/elements/1.1/> " + "SELECT * WHERE { ?name dc:name 'Mark John' }"
);
}
But it returns this:
instead of Mark John
and American
Basically, I want to output all data available for a person...in my case, name
and nationality
Your query returns exactly what the triple pattern in the query matches. You're asking for resources that have the name "Mark John" - and RDF resources are represented by URIs. Indeed your variable name is confusing since the name would be in the object position of the triple...
If you want to have the name again, you have to use a variable:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?name WHERE {
VALUES ?name {"Mark John"}
?s dc:name ?name .
}
And you don't select the nationality in your query. How to you expect that this will be returned then?
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?name ?ǹationality WHERE {
VALUES ?name {"Mark John"}
?s dc:name ?name ;
dc:nationality ?nationality .
}