Re: Re: Re: SPARQL QUERY STRING VARIABLES

2014-02-25 Thread Chris Dollin
On Monday, February 24, 2014 05:57:17 PM Nagore Salaberria wrote:
 I've tried what you mention me ... and does not work me.

Be specific.

What did you do and what happened? Was there a compiler error? Did
it compile but throw an exception when you ran it? Or did it successfully
produce the wrong answer?

Does not work doesn't give us much to go on.

Chris

-- 
We are on the brink of a new era, if only --  /The Beiderbeck Affair/

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: Re: Re: SPARQL QUERY STRING VARIABLES

2014-02-25 Thread Nagore Salaberria
What occurs to me is that the query does not give me any results because
the String does not appear in quotes and then not interpreted.

This is the query that generates me with* System.err.println(querys)*command :

PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
http://purl.org/goodrelations/v1#  PREFIX xsd: 
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),Elite AL13 Roller)) .
 ?m gr:quantitativeProductOrServiceProperty  ?ñ.
 ?ñ gr:hasValue ?h .
 FILTER (regex(str(?h),Rodillo)) .
 ?x gr:hasPriceSpecification ?ps .
 ?ps gr:hasCurrencyValue ?p .
 FILTER(?p = 200  ?p = 300 ) . }


and should be :

PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
http://purl.org/goodrelations/v1#  PREFIX xsd: 
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),Elite AL13 Roller)) .*
 ?m gr:quantitativeProductOrServiceProperty  ?ñ.
 ?ñ gr:hasValue ?h .
* FILTER (regex(str(?h),Rodillo)) .*
 ?x gr:hasPriceSpecification ?ps .
 ?ps gr:hasCurrencyValue ?p .
 FILTER(?p = 200  ?p = 300 ) . }

and the parameters are:

*FILTER (regex(str(?g),+a+)) .*

as you could add to that variable quotes?


Thank you,
Nagore.




2014-02-25 9:46 GMT+01:00 Chris Dollin chris.dol...@epimorphics.com:

 On Monday, February 24, 2014 05:57:17 PM Nagore Salaberria wrote:
  I've tried what you mention me ... and does not work me.

 Be specific.

 What did you do and what happened? Was there a compiler error? Did
 it compile but throw an exception when you ran it? Or did it successfully
 produce the wrong answer?

 Does not work doesn't give us much to go on.

 Chris

 --
 We are on the brink of a new era, if only --  /The Beiderbeck
 Affair/

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


Re: Re: Re: SPARQL QUERY STRING VARIABLES

2014-02-25 Thread Nagore Salaberria
Rob, I might give an example to see how to insert the class
ParameterizedSparqlString, I've been looking at examples but none puts you
where in the place it method.

Thank you,
Nagore.


2014-02-25 10:29 GMT+01:00 Nagore Salaberria nagore...@gmail.com:

 What occurs to me is that the query does not give me any results because
 the String does not appear in quotes and then not interpreted.

 This is the query that generates me with* System.err.println(querys)*command :

 PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
 http://purl.org/goodrelations/v1#  PREFIX xsd: 
 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),Elite AL13 Roller)) .
  ?m gr:quantitativeProductOrServiceProperty  ?ñ.
  ?ñ gr:hasValue ?h .
  FILTER (regex(str(?h),Rodillo)) .
  ?x gr:hasPriceSpecification ?ps .
  ?ps gr:hasCurrencyValue ?p .
  FILTER(?p = 200  ?p = 300 ) . }


 and should be :

 PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
 http://purl.org/goodrelations/v1#  PREFIX xsd: 
 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),Elite AL13 Roller)) .*
  ?m gr:quantitativeProductOrServiceProperty  ?ñ.
  ?ñ gr:hasValue ?h .
 * FILTER (regex(str(?h),Rodillo)) .*
  ?x gr:hasPriceSpecification ?ps .
  ?ps gr:hasCurrencyValue ?p .
  FILTER(?p = 200  ?p = 300 ) . }

 and the parameters are:

 *FILTER (regex(str(?g),+a+)) .*

 as you could add to that variable quotes?


 Thank you,
 Nagore.




 2014-02-25 9:46 GMT+01:00 Chris Dollin chris.dol...@epimorphics.com:

 On Monday, February 24, 2014 05:57:17 PM Nagore Salaberria wrote:
  I've tried what you mention me ... and does not work me.

 Be specific.

 What did you do and what happened? Was there a compiler error? Did
 it compile but throw an exception when you ran it? Or did it successfully
 produce the wrong answer?

 Does not work doesn't give us much to go on.

 Chris

 --
 We are on the brink of a new era, if only --  /The Beiderbeck
 Affair/

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




-- 
Nagore Salaberrianagore...@gmail.com


Re: SPARQL query string variables

2014-02-25 Thread Chris Dollin
On Tuesday, February 25, 2014 10:29:32 AM Nagore Salaberria wrote:

 
 and the parameters are:
 
 *FILTER (regex(str(?g),+a+)) .*
 
 as you could add to that variable quotes?
 

As I said earlier, write a quote() method and then call it in
the appropriate places:

   \nFILTER (regex(str(?g),  + quote(a) + )).

Chris

-- 
Possibly you're not recalling some of his previous plans.  Zoe, /Firefly/

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

2014-02-25 Thread Nagore Salaberria
and what is the quoate() method?


2014-02-25 11:49 GMT+01:00 Chris Dollin chris.dol...@epimorphics.com:

 On Tuesday, February 25, 2014 10:29:32 AM Nagore Salaberria wrote:

 
  and the parameters are:
 
  *FILTER (regex(str(?g),+a+)) .*
 
  as you could add to that variable quotes?
 

 As I said earlier, write a quote() method and then call it in
 the appropriate places:

\nFILTER (regex(str(?g),  + quote(a) + )).

 Chris

 --
 Possibly you're not recalling some of his previous plans.  Zoe,
 /Firefly/

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


Re: Re: SPARQL query string variables

2014-02-25 Thread Chris Dollin
On Tuesday, February 25, 2014 11:55:00 AM Nagore Salaberria wrote:
 and what is the quoate() method?

I told you how to write it in a previous post.

Chris

-- 
People are part of the design. It's dangerous to forget that. /Star Cops/

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

2014-02-25 Thread Rob Vesse
See the staged documentation at
http://jena.staging.apache.org/documentation/query/parameterized-sparql-str
ings.html

Rob

On 25/02/2014 09:45, Nagore Salaberria nagore...@gmail.com wrote:

Rob, I might give an example to see how to insert the class
ParameterizedSparqlString, I've been looking at examples but none puts you
where in the place it method.

Thank you,
Nagore.


2014-02-25 10:29 GMT+01:00 Nagore Salaberria nagore...@gmail.com:

 What occurs to me is that the query does not give me any results because
 the String does not appear in quotes and then not interpreted.

 This is the query that generates me with*
System.err.println(querys)*command :

 PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
 http://purl.org/goodrelations/v1#  PREFIX xsd: 
 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),Elite AL13 Roller)) .
  ?m gr:quantitativeProductOrServiceProperty  ?ñ.
  ?ñ gr:hasValue ?h .
  FILTER (regex(str(?h),Rodillo)) .
  ?x gr:hasPriceSpecification ?ps .
  ?ps gr:hasCurrencyValue ?p .
  FILTER(?p = 200  ?p = 300 ) . }


 and should be :

 PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
 http://purl.org/goodrelations/v1#  PREFIX xsd: 
 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),Elite AL13 Roller)) .*
  ?m gr:quantitativeProductOrServiceProperty  ?ñ.
  ?ñ gr:hasValue ?h .
 * FILTER (regex(str(?h),Rodillo)) .*
  ?x gr:hasPriceSpecification ?ps .
  ?ps gr:hasCurrencyValue ?p .
  FILTER(?p = 200  ?p = 300 ) . }

 and the parameters are:

 *FILTER (regex(str(?g),+a+)) .*

 as you could add to that variable quotes?


 Thank you,
 Nagore.




 2014-02-25 9:46 GMT+01:00 Chris Dollin chris.dol...@epimorphics.com:

 On Monday, February 24, 2014 05:57:17 PM Nagore Salaberria wrote:
  I've tried what you mention me ... and does not work me.

 Be specific.

 What did you do and what happened? Was there a compiler error? Did
 it compile but throw an exception when you ran it? Or did it
successfully
 produce the wrong answer?

 Does not work doesn't give us much to go on.

 Chris

 --
 We are on the brink of a new era, if only --  /The Beiderbeck
 Affair/

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




-- 
Nagore Salaberrianagore...@gmail.com






Re: SPARQL query string variables

2014-02-25 Thread Rob Vesse
We are not going to do your project for you!

Btw Chris actually gave you an example implementation of this method
further back in the email thread if you'd actually been paying attention

Rob

On 25/02/2014 10:55, Nagore Salaberria nagore...@gmail.com wrote:

and what is the quoate() method?


2014-02-25 11:49 GMT+01:00 Chris Dollin chris.dol...@epimorphics.com:

 On Tuesday, February 25, 2014 10:29:32 AM Nagore Salaberria wrote:

 
  and the parameters are:
 
  *FILTER (regex(str(?g),+a+)) .*
 
  as you could add to that variable quotes?
 

 As I said earlier, write a quote() method and then call it in
 the appropriate places:

\nFILTER (regex(str(?g),  + quote(a) + )).

 Chris

 --
 Possibly you're not recalling some of his previous plans.  Zoe,
 /Firefly/

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






Re: SPARQL QUERY STRING VARIABLES

2014-02-25 Thread Nagore Salaberria
Excuse me why Chris had misunderstood your explanation on quote () method,
it works well indeed, thank you!


Regards,
Nagore.


2014-02-25 12:23 GMT+01:00 Rob Vesse rve...@dotnetrdf.org:

 See the staged documentation at
 http://jena.staging.apache.org/documentation/query/parameterized-sparql-str
 ings.html

 Rob

 On 25/02/2014 09:45, Nagore Salaberria nagore...@gmail.com wrote:

 Rob, I might give an example to see how to insert the class
 ParameterizedSparqlString, I've been looking at examples but none puts you
 where in the place it method.
 
 Thank you,
 Nagore.
 
 
 2014-02-25 10:29 GMT+01:00 Nagore Salaberria nagore...@gmail.com:
 
  What occurs to me is that the query does not give me any results because
  the String does not appear in quotes and then not interpreted.
 
  This is the query that generates me with*
 System.err.println(querys)*command :
 
  PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
  http://purl.org/goodrelations/v1#  PREFIX xsd: 
  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),Elite AL13 Roller)) .
   ?m gr:quantitativeProductOrServiceProperty  ?ñ.
   ?ñ gr:hasValue ?h .
   FILTER (regex(str(?h),Rodillo)) .
   ?x gr:hasPriceSpecification ?ps .
   ?ps gr:hasCurrencyValue ?p .
   FILTER(?p = 200  ?p = 300 ) . }
 
 
  and should be :
 
  PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#  PREFIX gr: 
  http://purl.org/goodrelations/v1#  PREFIX xsd: 
  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),Elite AL13 Roller)) .*
   ?m gr:quantitativeProductOrServiceProperty  ?ñ.
   ?ñ gr:hasValue ?h .
  * FILTER (regex(str(?h),Rodillo)) .*
   ?x gr:hasPriceSpecification ?ps .
   ?ps gr:hasCurrencyValue ?p .
   FILTER(?p = 200  ?p = 300 ) . }
 
  and the parameters are:
 
  *FILTER (regex(str(?g),+a+)) .*
 
  as you could add to that variable quotes?
 
 
  Thank you,
  Nagore.
 
 
 
 
  2014-02-25 9:46 GMT+01:00 Chris Dollin chris.dol...@epimorphics.com:
 
  On Monday, February 24, 2014 05:57:17 PM Nagore Salaberria wrote:
   I've tried what you mention me ... and does not work me.
 
  Be specific.
 
  What did you do and what happened? Was there a compiler error? Did
  it compile but throw an exception when you ran it? Or did it
 successfully
  produce the wrong answer?
 
  Does not work doesn't give us much to go on.
 
  Chris
 
  --
  We are on the brink of a new era, if only --  /The Beiderbeck
  Affair/
 
  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 Salaberrianagore...@gmail.com
 
 
 
 
 --
 Nagore Salaberrianagore...@gmail.com







-- 
Nagore Salaberrianagore...@gmail.com


Re: SPARQL QUERY STRING VARIABLES

2014-02-24 Thread Andy Seaborne

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

2014-02-24 Thread Chris Dollin
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)



Re: SPARQL QUERY STRING VARIABLES

2014-02-24 Thread Nagore Salaberria
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 a...@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 Salaberrianagore...@gmail.com


Re: SPARQL QUERY STRING VARIABLES

2014-02-24 Thread Nagore Salaberria
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 nagore...@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 a...@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 Salaberrianagore...@gmail.com




-- 
Nagore Salaberrianagore...@gmail.com


Re: SPARQL QUERY STRING VARIABLES

2014-02-24 Thread Rob Vesse
FYI attachments are not permitted on this list

What Chris and Andy are suggesting is that you print out your string after
constructing it e.g.

System.out.println(querys);

Secondly if you follow their suggestions and add new lines to your query
the error message will point you more directly to the point in the query
where the error occurs.  Currently your query is one single line hence why
the error message reports an error at line 1, column 331.

Rob

On 24/02/2014 15:54, Nagore Salaberria nagore...@gmail.com wrote:

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 nagore...@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 a...@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 Salaberrianagore...@gmail.com




-- 
Nagore Salaberrianagore...@gmail.com






Re: SPARQL QUERY STRING VARIABLES

2014-02-24 Thread Nagore Salaberria
The problem is that when the variables of type String get well, they need
some quotes   and to insert them into the query as + b + does not know
how to attach the quotes.


\n FILTER (regex(str(?g),*+g+*)) . +

is
\n FILTER (regex(str(?g),Rodillo)) . +

and shourd be:

\n FILTER (regex(str(?g),Rodillo)) . +




Thank  you,
Nagore.



2014-02-24 17:34 GMT+01:00 Rob Vesse rve...@dotnetrdf.org:

 FYI attachments are not permitted on this list

 What Chris and Andy are suggesting is that you print out your string after
 constructing it e.g.

 System.out.println(querys);

 Secondly if you follow their suggestions and add new lines to your query
 the error message will point you more directly to the point in the query
 where the error occurs.  Currently your query is one single line hence why
 the error message reports an error at line 1, column 331.

 Rob

 On 24/02/2014 15:54, Nagore Salaberria nagore...@gmail.com wrote:

 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 nagore...@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 a...@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 Salaberrianagore...@gmail.com
 
 
 
 
 --
 Nagore Salaberrianagore...@gmail.com







-- 
Nagore Salaberrianagore...@gmail.com


Re: SPARQL QUERY STRING VARIABLES

2014-02-24 Thread Rob Vesse
Or even better use ParameterizedSparqlString to build your queries and
insert parameters -
http://jena.apache.org/documentation/query/parameterized-sparql-strings.htm
l

Rob

On 24/02/2014 16:55, Chris Dollin chris.dol...@epimorphics.com wrote:

On Monday, February 24, 2014 05:37:10 PM Nagore Salaberria wrote:
 The problem is that when the variables of type String get well, they
need
 some quotes   and to insert them into the query as + b + does not
know
 how to attach the quotes.

You'll have to put the quotes in yourself.

I suggest writing a method `quote` which quotes strings: to begin with

static String quote(String x) {
   return \ + x + \;
}

and then you can write

 \n FILTER (regex(str(?g),*+quote(g)+*)) . +

of course this breaks as soon as `g` might contain quotes or
backslashes, in which case I suggest

return \ + FmtUtils(stringEsc(x, true) + \;

which is a method from ARQ that properly quotes strings for SPARQL.

Chris

-- 
- 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)