forgive me if the message is not well understood, here are the file so you can better see the code.
2014-02-24 16:46 GMT+01:00 Andy Seaborne <[email protected]>: > On 24/02/14 15:39, Nagore Salaberria wrote: > >> hello, >> >> I am running my input SPARQL query and you want to insert two and two >> intenger and String. The problem I have with the introduction of variables >> the type String, once I run it gives me the following error: >> >> *Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: >> >> Lexical error at line 1, column 331. Encountered: " " (32), after : >> > > Print variable "querys" out after construction and see the error. > > If you put newlines in the query string, it'll be easier to read. > > (Your email is fairly unreadable) > > Andy > > > "Elite"* >> * at >> com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform( >> ParserSPARQL11.java:111)* >> * at >> com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$( >> ParserSPARQL11.java:53)* >> * at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse( >> SPARQLParser.java:37)* >> * at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:139)* >> * at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:79)* >> * at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:52)* >> * at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)* >> * at tutorial.rodillos.sparqlTest3(rodillos.java:53)* >> * at tutorial.rodillos.main(rodillos.java:20)* >> >> >> This is my code: >> >> >> >> *public class rodillos {* >> >> *public static void main(String args[])* >> * {* >> * try {* >> * sparqlTest3( "Elite AL13 Roller" ,"Rodillo",200,300 );* >> * } catch (UnsupportedEncodingException e) {* >> * // TODO Auto-generated catch block* >> * e.printStackTrace();* >> * }* >> * }* >> >> >> *public static void sparqlTest3(String g, String h,int a, int b) throws >> UnsupportedEncodingException * >> * {* >> * >> FileManager.get().addLocatorClassLoader(elipticas.class. >> getClassLoader());* >> * Model model = FileManager.get().loadModel("RDF/rodillo.rdf");* >> * String querys = * >> * " PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns# >> <http://www.w3.org/1999/02/22-rdf-syntax-ns#>> " +* >> * " PREFIX gr: <http://purl.org/goodrelations/v1# >> <http://purl.org/goodrelations/v1#>> " +* >> * " PREFIX xsd: <http://www.w3.org/2001/XMLSchema# >> <http://www.w3.org/2001/XMLSchema#>> " +* >> * " SELECT * WHERE {" +* >> * " ?x a gr:Offering . " +* >> * " ?x gr:includes ?m . " +* >> * " ?m gr:name ?z ." +* >> * " ?m gr:quantitativeProductOrServiceProperty ?s . " +* >> * " ?s gr:hasValue ?g ." +* >> * " FILTER (regex(str(?g),"+g+")) ." +* >> * " ?m gr:quantitativeProductOrServiceProperty ?ñ. " +* >> * " ?ñ gr:hasValue ?h ." +* >> * " FILTER (regex(str(?h),"+h+")) ." +* >> * " ?x gr:hasPriceSpecification ?ps ." +* >> * " ?ps gr:hasCurrencyValue ?p . " +* >> * " FILTER(?p >= "+a+" && ?p <= "+b+" ) . " +* >> * "}";* >> * com.hp.hpl.jena.query.Query query = QueryFactory.create(querys);* >> * QueryExecution qexec = QueryExecutionFactory.create(query, model);* >> * try {* >> * ResultSet results = qexec.execSelect();* >> * while ( results.hasNext() ) {* >> * QuerySolution soln = results.nextSolution();* >> * Literal name = soln.getLiteral("z");* >> * System.out.println(name);* >> >> * }* >> * } finally {* >> * qexec.close();* >> * }* >> *}* >> >> >> Thank you, >> Nagore. >> >> >> >> >> >> > -- Nagore Salaberria<[email protected]>
