You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Nagore Salaberria <na...@gmail.com> on 2014/02/24 16:39:14 UTC

SPARQL QUERY STRING VARIABLES

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 :
"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<na...@gmail.com>

Re: Re: Sparql query string variables

Posted by Chris Dollin <ch...@epimorphics.com>.
On Monday, February 24, 2014 04:54:44 PM Nagore Salaberria wrote:
> I don´t understand Chris, you can put me an example so you can see better.
> 

Print the query out:

    System.err.println(querys);

You will see that you get the whole query on a single line, which
is very hard to read, and the error message will just tell you
line 1 (there is only one line) and probably a character position
like 79 or 113 which is hard to relate to the line.

You need line-breaks in the query string, so FOR EXAMPLE the line

    " ?m gr:quantitativeProductOrServiceProperty  ?s . " +

becomes:

    "\n ?m gr:quantitativeProductOrServiceProperty  ?s . " +

so that `?m gr:quantitativeProductOrServiceProperty  ?s .` comes
out on a new line. 

Do that to all your querys lines and then print the querys. Not
the code -- the query string. The error will probably be obvious.

Chris

PS don't put subject lines in all-caps. Don't past code into your
message with all those extra *s -- it makes the code harder to read.

> 2014-02-24 16:52 GMT+01:00 Nagore Salaberria <na...@gmail.com>:
> 
> > 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 <an...@apache.org>:
> >
> > 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<na...@gmail.com>
> >
> 
> 
> 
> 

-- 
"I don't want to know what the Structuralists think! I want     /Archer's Goon/
 to know what YOU think!"

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)


Re: SPARQL QUERY STRING VARIABLES

Posted by Nagore Salaberria <na...@gmail.com>.
I don´t understand Chris, you can put me an example so you can see better.

Thank You,
Nagore.


2014-02-24 16:52 GMT+01:00 Nagore Salaberria <na...@gmail.com>:

> 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 <an...@apache.org>:
>
> 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<na...@gmail.com>
>



-- 
Nagore Salaberria<na...@gmail.com>

Re: SPARQL QUERY STRING VARIABLES

Posted by Nagore Salaberria <na...@gmail.com>.
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 <an...@apache.org>:

> 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<na...@gmail.com>

Re: SPARQL QUERY STRING VARIABLES

Posted by Andy Seaborne <an...@apache.org>.
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.
>
>
>
>
>


Re: SPARQL QUERY STRING VARIABLES

Posted by Chris Dollin <ch...@epimorphics.com>.
On Monday, February 24, 2014 04:39:14 PM Nagore Salaberria wrote:
> 
> 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();*
> *    }*
> *}*

Put newlines in your query. (At the beginning or end of your strings.)

Print it out or look at it in an editor, especially if it can show
line numbers.

Then you can see where the problem is & it will likely be obvious
how to fix it.

Chris

-- 
"Some of these", Hazleton had said, looking at a           /A Clash of Cymbals/
 just-completed tangle of wires, lenses, antennae and
 kernels of metal with rueful respect, "ought to prove pretty potent in the
 pinch. I just wish I knew which ones they were."

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)