BOnjour a tous!
J'ai un petit probleme en essayant de faire une requete SPARQL sur un fichier RDF avec la recherche entree par l'utilisateur.
Mon code m'afficher une erreur que je n'arrive pas a discerner.
Le contenu de mon RDF fichier:
Mon Code Java
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rss="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/xhtml"> <foaf:Agent rdf:nodeID="id2251035"> <foaf:name>Planet</foaf:name> <foaf:weblog> <foaf:Document rdf:about="http://blog.planetrdf.com/"> <dc:title>Planet RDF site blog</dc:title> <rdfs:seeAlso> <rss:channel rdf:about="http://blog.planetrdf.com/rss.xml"> <foaf:maker rdf:nodeID="id2251035"/> <foaf:topic rdf:resource="http://www.w3.org/2001/sw/"/> <foaf:topic rdf:resource="http://www.w3.org/RDF/"/> </rss:channel> </rdfs:seeAlso> </foaf:Document> </foaf:weblog> <foaf:interest rdf:resource="http://www.w3.org/2001/sw/"/> <foaf:interest rdf:resource="http://www.w3.org/RDF/"/> </foaf:Agent>
L'erreur que je recois :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 String queryString = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> " + "SELECT ?url " + "WHERE {" + " ?contributor foaf:name "+nayme.toString()+" . " + // quand je remplace cette ligne par " ?contributor foaf:name \"Planet\" . " + Il ny a pas de problem " ?contributor foaf:weblog ?url . " + " }";
Avec Planet la recherche entree par lutilisateur a partir du clavier. Quand jessaie de mettre la valeur directement dans le code, il n'ya pas de probleme. Je suppose donc que c'est au niveau de la syntaxe.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 com.hp.hpl.jena.query.QueryParseException: Lexical error at line 1, column 97. Encountered: " " (32), after : "Planet"
Merci pour votre aide
Partager