Hello,

The SPARQL query works fine if I apply without the input variables, but if
you apply the filter variables gives me this error:



*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.

-- 
Nagore Salaberria<[email protected]>

Reply via email to