Reputation: 83
my project is about enabling the user to enter the query and the best results are to be displayed to the user.this is my RDF file
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:foaf="http://www.xmlns.com/foaf/0.1">
<rdf:Description>
<foaf:name>interview</foaf:name>
<foaf:url>urlname1</foaf:url>
</rdf:Description>
<rdf:Description>
<foaf:name>technical</foaf:name>
<foaf:url>urlname2</foaf:url>
</rdf:Description> </rdf:RDF>
now if the user enters "technical questions",i coded in the way to take "technical" and "questions" in a array and to dynamically generate a SPARQL query so my query will look like
String queryString = "PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# " + "PREFIX foaf: http://www.xmlns.com/foaf/0.1 " + "SELECT ?url WHERE { ?a foaf:name ?name FILTER regex(?name,'"+ values[i]+"') ?a foaf:url ?url.}";
here values[i] is the array defined for "technical" and "questions".so this gives me an output as
------------- | url | ============= | "urlname2"| -------------
and when the user enters "interview questions" the result would be
------------- | url | ============= | "urlname1"| -------------
But if the user enters "technical interview questions" it gives me both as o/p like
------------- | url | ============= | "urlname2"| ------------- ------------- | url | ============= | "urlname1"| -------------
but the o/p which i should get is only the first table that gives me url to prepare for technical questions(urlname2).can you please tell me how to alter my query/RDF format to get the desired o/p ? Thank you
Upvotes: 1
Views: 589
Reputation: 3660
The data doesn't mean what you think it does.
You have one object, with two different foaf:names.
Try converting the RDF/XML into Turtle or NTriples to get a clearer view of the data RDF/XML is very confusing.
Upvotes: 3