开发者

how to search rdf with sparql using java?

I am doing project in semantic web where i use SPARQL to query rdf data. I used java in netbeans and my problem is my program runs,inputs the rdf file and the query executes but the WHERE area of my query is not considered. (i.e) i get a empty table as output

Can you please tel me any suggestions of S开发者_Go百科PARQL syntax in JAVA to retrieve all name,phone number from rdf file


"WHERE area of my query is not considered. (i.e) i get a empty table as output"

I doubt the WHERE clause is not being considered. An empty table suggests a) you have no data or b) your query has no matches.

Retrieving all names and phone number depends on the vocabulary used, but the most common by far is foaf:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name, ?number
WHERE
{
    ?person foaf:name ?name .
    ?person foaf:phone ?number .
}

We need more information, so here's some generic advice:

  1. Try SELECT * WHERE { ?s ?p ?o }. Is that getting results? If not, try...
  2. Try SELECT * WHERE { graph ?g { ?s ?p ?o } }. Is that getting results?

If neither are working you may have issues with you data. If only the second gets result you check you are querying graphs.

This will give you a good idea about what you have loaded either way. If it looks ok:

  1. Remove an element of your WHERE clause.
  2. If you still get no results go to 1.
  3. If you get results you have found an issue with your query.

You can also try replacing terms with variables. Working this way might help track down which elements are causing the query to fail.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜