You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Charles Li <ch...@gmail.com> on 2013/12/11 06:38:18 UTC
Different namespace strings running SPARQL query in Fuseki Web
Console vs using Jena API
Hi, Jena and SPARQL experts:
I have the following SPARQL query:
--------------------------------------------------------------------------------
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX my: <http://www.mycompany.com/me1.0#>
select ?type where { <my#xyz> rdf:type ?type }
--------------------------------------------------------------------------------
When I run it inside the Fuseki web console, the result is: "my.MyType".
However, when I use the following code to run in Jena 2.10.1:
--------------------------------------------------------------------------------
Query query = QueryFactory.create(queryString); //the above
query string in entirety
QueryExecution qexec = QueryExecutionFactory.create(query, model);
ResultSet results = qexec.execSelect();
QuerySolution soln = null;
String rdfClassName = null;
if(results.hasNext()) {
soln = results.nextSolution();
rdfClassName = soln.get("?type").toString();
}
--------------------------------------------------------------------------------
rdfClassName contains string "http://www.mycompany.com/me1.0#MyType".
My question is: how do I write the Jena code to have refClassName also
contains "my.MyType"?
Thanks a lot for your help!
- Charles
Re: Different namespace strings running SPARQL query in Fuseki Web
Console vs using Jena API
Posted by Dave Reynolds <da...@gmail.com>.
On 11/12/13 05:38, Charles Li wrote:
> Hi, Jena and SPARQL experts:
>
> I have the following SPARQL query:
> --------------------------------------------------------------------------------
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX my: <http://www.mycompany.com/me1.0#>
> select ?type where { <my#xyz> rdf:type ?type }
> --------------------------------------------------------------------------------
>
> When I run it inside the Fuseki web console, the result is: "my.MyType".
It's probably my:MyType
> However, when I use the following code to run in Jena 2.10.1:
> --------------------------------------------------------------------------------
> Query query = QueryFactory.create(queryString); //the above
> query string in entirety
> QueryExecution qexec = QueryExecutionFactory.create(query, model);
> ResultSet results = qexec.execSelect();
> QuerySolution soln = null;
> String rdfClassName = null;
> if(results.hasNext()) {
> soln = results.nextSolution();
> rdfClassName = soln.get("?type").toString();
> }
>
> --------------------------------------------------------------------------------
>
> rdfClassName contains string "http://www.mycompany.com/me1.0#MyType".
>
> My question is: how do I write the Jena code to have refClassName also
> contains "my.MyType"?
model.shortForm( rdfClassName )
Dave