thank you, Nagore
2014-02-17 17:43 GMT+01:00 Chris Dollin <[email protected]>: > On Monday, February 17, 2014 05:24:41 PM Nagore Salaberria wrote: > > Hello, > > > > The SPARQL query works fine if I apply without the input variables, but > if > > you apply the filter variables gives me this error: > > (1) Variables are prefixed with ?, so I think you want > > > FILTER(?p >= ?a && ?p <= ?b ) > > (2) Put newlines in your queries so that you can print them out > and match up the line numbers reported by the parser with > the text of the line. It was a bit tedious working out where > "column 289" was. > > > *Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: > > Encountered " "a" "a "" at line 1, column 289.* > > *Was expecting one of:* > > * <IRIref> ...* > > * <PNAME_NS> ...* > > * <PNAME_LN> ...* > > * <VAR1> ...* > > * <VAR2> ...* > > * "exists" ...* > > * "not" ...* > > * "count" ...* > > * "min" ...* > > * "max" ...* > > * "sum" ...* > > * "avg" ...* > > * "sample" ...* > > * "group_concat" ...* > > * "bound" ...* > > * "coalesce" ...* > > * "if" ...* > > * "bnode" ...* > > * "iri" ...* > > * "uri" ...* > > * "str" ...* > > * "strlang" ...* > > * "strdt" ...* > > * "datatype" ...* > > * "lang" ...* > > * "langmatches" ...* > > * "isURI" ...* > > * "isIRI" ...* > > * "isBlank" ...* > > * "isLiteral" ...* > > * "isNumeric" ...* > > * "regex" ...* > > * "sameTerm" ...* > > * "RAND" ...* > > * "ABS" ...* > > * "CEIL" ...* > > * "FLOOR" ...* > > * "ROUND" ...* > > * "CONCAT" ...* > > * "SUBSTR" ...* > > * "STRLEN" ...* > > * "REPLACE" ...* > > * "UCASE" ...* > > * "LCASE" ...* > > * "ENCODE_FOR_URI" ...* > > * "CONTAINS" ...* > > * "STRSTARTS" ...* > > * "STRENDS" ...* > > * "STRBEFORE" ...* > > * "STRAFTER" ...* > > * "YEAR" ...* > > * "MONTH" ...* > > * "DAY" ...* > > * "HOURS" ...* > > * "MINUTES" ...* > > * "SECONDS" ...* > > * "TIMEZONE" ...* > > * "TZ" ...* > > * "NOW" ...* > > * "UUID" ...* > > * "STRUUID" ...* > > * "MD5" ...* > > * "SHA1" ...* > > * "SHA256" ...* > > * "SHA384" ...* > > * "SHA512" ...* > > * "true" ...* > > * "false" ...* > > * <INTEGER> ...* > > * <DECIMAL> ...* > > * <DOUBLE> ...* > > * <INTEGER_POSITIVE> ...* > > * <DECIMAL_POSITIVE> ...* > > * <DOUBLE_POSITIVE> ...* > > * <INTEGER_NEGATIVE> ...* > > * <DECIMAL_NEGATIVE> ...* > > * <DOUBLE_NEGATIVE> ...* > > * <STRING_LITERAL1> ...* > > * <STRING_LITERAL2> ...* > > * <STRING_LITERAL_LONG1> ...* > > * <STRING_LITERAL_LONG2> ...* > > * "(" ...* > > * "!" ...* > > * "+" ...* > > * "-" ...* > > > > * at > > > com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:102)* > > * 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.elipticas.sparqlTest2(elipticas.java:46)* > > * at tutorial.elipticas.main(elipticas.java:20)* > > > > > > this is my code: > > > > *package tutorial;* > > > > *import java.io.UnsupportedEncodingException;* > > > > *import com.hp.hpl.jena.query.QueryExecution;* > > *import com.hp.hpl.jena.query.QueryExecutionFactory;* > > *import com.hp.hpl.jena.query.QueryFactory;* > > *import com.hp.hpl.jena.query.QuerySolution;* > > *import com.hp.hpl.jena.query.ResultSet;* > > *import com.hp.hpl.jena.rdf.model.Literal;* > > *import com.hp.hpl.jena.rdf.model.Model;* > > *import com.hp.hpl.jena.util.FileManager;* > > > > *public class elipticas {* > > > > * public static void main(String args[])* > > * {* > > * try {* > > * sparqlTest2(300,800);* > > * } catch (UnsupportedEncodingException e) {* > > * // TODO Auto-generated catch block* > > * e.printStackTrace();* > > * }* > > * }* > > > > *public static void sparqlTest2(int a, int b) throws > > UnsupportedEncodingException * > > * {* > > * > > > FileManager.get().addLocatorClassLoader(elipticas.class.getClassLoader());* > > * Model model = FileManager.get().loadModel("RDF/elipticas.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:name ?d . " +* > > * " ?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("d");* > > * System.out.println(name);* > > > > * }* > > * } finally {* > > * qexec.close();* > > * }* > > *}* > > *} * > > > > > > Thank you, > > Nagore. > > > > > > -- > "- no longer a stranger to the truth." - The Reasoning, > /Awakening/ > > Epimorphics Ltd, http://www.epimorphics.com > Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 > 6PT > Epimorphics Ltd. is a limited company registered in England (number > 7016688) > > -- Nagore Salaberria<[email protected]>
