Thank you for your response.
But your response is nothing to do with me.

* character in SELECT clause means all variables bound in WHERE clause.
So my test query works well on SPARQL endpoint even if I do not use "SELECT ?x" 
instead of "SELECT *".

Please let me know how to figure out encoding problem when query string 
contains Korean characters.

Sincerely yours,
Myungjin Lee


-----Original Message-----
From: Miguel Bento Alves [mailto:[email protected]] 
Sent: Thursday, November 06, 2014 6:41 PM
To: [email protected]
Subject: Re: Problem SPARQL query encoding

Hi, 

you only can get the variables that are in Select clause. Try this and will 
work:

….
String allSameAsQuery = ""
                        + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
                        + "SELECT ?x\n" + "WHERE {\n"
                        + "  <http://ko.dbpedia.org/resource/문절망둑> owl:sameAs 
?x .\n" + "}"; ….

"SELECT ?x” instead of "SELECT *”

Miguel


> On 06 Nov 2014, at 09:29, 이명진 <[email protected]> wrote:
> 
> Thank you for your response.
> 
> My question is that my test code does not work if SPARQL query has Korean 
> characters because query string is encoded.
> My test code is:
> 
>               String dbpediKoEndpoint = "http://ko.dbpedia.org/sparql";;
>               String allSameAsQuery = ""
>                       + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
>                       + "SELECT *\n" + "WHERE {\n"
>                       + "  <http://ko.dbpedia.org/resource/문절망둑> owl:sameAs 
> ?x .\n" + "}";
>               Query query = QueryFactory.create(allSameAsQuery);
>               QueryEngineHTTP httpQuery = new 
> QueryEngineHTTP(dbpediKoEndpoint, query);
>               ResultSet results = httpQuery.execSelect();
>               while (results.hasNext()) {
>                       QuerySolution solution = results.next();
>                       String species = solution.getResource("?x").getURI();
>                       System.out.println(species);
>               }
> 
> If you input SPARQL query like below on http://ko.dbpedia.org/sparql, you can 
> get 9 resources.
> 
> PREFIX  owl:  <http://www.w3.org/2002/07/owl#>
> 
> SELECT  *
> WHERE
>  { <http://ko.dbpedia.org/resource/문절망둑> owl:sameAs ?x }
> 
> This query is the same as SPARQL query in my test code.
> Thank you.
> 
> Sincerely yours,
> Dr. Myungjin Lee
> 
> 
> -----Original Message-----
> From: Miguel Bento Alves [mailto:[email protected]]
> Sent: Thursday, November 06, 2014 5:24 PM
> To: [email protected]
> Subject: Re: Problem SPARQL query encoding
> 
> Hi Myunjin,
> 
> what you did is not enough. You need to create a QueryExecution and create a 
> ResultSet to have a cursor pointing to the results.
> See the example below. 
> 
> Miguel
> 
> 
>       String service = "http://dbpedia.org/sparql";;
>        String query = "select distinct ?Concept where {[] a ?Concept} LIMIT 
> 100";
>        QueryExecution qe 
>                = QueryExecutionFactory.sparqlService(service, query);
> 
>        ResultSet rs = qe.execSelect();
> 
>        while(rs.hasNext()) {
>            QuerySolution qs = rs.next();
>            System.out.println("Concept -> "+qs.get("Concept").toString());
>        }
> 
>> On 06 Nov 2014, at 07:13, 이명진 <[email protected]> wrote:
>> 
>> Hello. My name is Myunjin Lee.
>> 
>> I am testing simple SPARQL query from Korean DBpedia SPARQL
>> endpoint(http://ko.dbpedia.org/sparql) using Jena.
>> 
>> For that, I implemented simple test code, but I had URI encoding 
>> problem of SPARQL query that has Korean character.
>> 
>> 
>> 
>> My simple query is:
>> 
>> 
>> 
>>       String allSameAsQuery = ""
>> 
>>                      + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
>> 
>>                      + "SELECT *\n" + "WHERE {\n"
>> 
>>                      + "  <http://ko.dbpedia.org/resource/문절망둑>
>> owl:sameAs ?x .\n" + "}";
>> 
>> 
>> 
>> And then, to process query, I construct Query object.
>> 
>> 
>> 
>> Query query = QueryFactory.create(allSameAsQuery);
>> 
>> System.out.println(query.toString());
>> 
>> 
>> 
>> Problem is that the query string is encoded when I make a Query object.
>> Print out result is:
>> 
>> 
>> 
>> PREFIX  owl:  <http://www.w3.org/2002/07/owl#>
>> 
>> 
>> 
>> SELECT  *
>> 
>> WHERE
>> 
>> {
>> <http://ko.dbpedia.org/resource/%EB%AC%B8%EC%A0%88%EB%A7%9D%EB%91%91>
>> owl:sameAs ?x }
>> 
>> 
>> 
>> So that, I cannot get any owl:sameAs resource.
>> 
>> 
>> 
>> How can I figure out the encoding problem? Or is there any method for 
>> my problem?
>> 
>> Thank for your help.
>> 
>> 
>> 
>> Sincerely yours,
>> 
>> Dr. Myungjin Lee
>> 
> 
> 


Reply via email to