Ciao Amir,
As far as I understood the transitive option is a Virtuoso extension, that
means it is not defined in SPARQL 1.1 (used by Jena).
That means Jena will fail with a parser exception when trying to parse your
query.
You might want to read [1] which could have a solution for you.
Regards
Andrea
[1]
http://blog.pingoured.fr/index.php?post/2011/10/11/Jena%2C-virtuoso-and-option-transitive
Il giorno 01/mar/2013 08:45, "Amir Hossein Jadidinejad" <
amir.jad...@yahoo.com> ha scritto:
> Hi,
> check the following function:
> public boolean isConceptType(String uri, String ctype) {
> uri = "<" + uri + ">";
> boolean results = false;
> String queryString = "PREFIX rdfs: <
> http://www.w3.org/2000/01/rdf-schema#>\n" +
> "PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>\n" +
> "ASK {\n" + " {\n " + uri + " a ?p .\n"
> + " ?p rdfs:subClassOf dbpedia-owl:" + ctype
> + " OPTION (transitive).\n" + " }\n" + "UNION\n" + "
> {\n "
> + uri + " a dbpedia-owl:Place .\n" + " }\n" + "}";
> // --now creating query object
> Query query = QueryFactory.create(queryString);
> // --initializing queryExecution factory with remote service.
> QueryExecution qexec = QueryExecutionFactory.sparqlService(
> "http://dbpedia.org/sparql", query);
> try {
> results = qexec.execAsk();
> } finally {
> qexec.close();
> }
> return results;
> }
>
>
> In the debug mode, the value of "queryString" is something like this:
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
> ASK {
> {
> <http://dbpedia.org/resource/Iran> a ?p .
> ?p rdfs:subClassOf dbpedia-owl:Place OPTION (transitive).
> }
> UNION
> {
> <http://dbpedia.org/resource/Iran> a dbpedia-owl:Place .
> }
> }
>
> This query is running in Virtuoso SPARQL query
> editor<http://dbpedia-live.openlinksw.com/sparql>but make the following error:
> Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Lexical
> error at line 6, column 48. Encountered: " " (32), after : "OPTION"
> 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.Parser.parse(Parser.java:37)
> at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:156)
> 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
> it.uniroma1.lcl.msm2013.RunExperiments.isConceptType(RunExperiments.java:175)
> at it.uniroma1.lcl.msm2013.RunExperiments.main(RunExperiments.java:286)
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Dbpedia-discussion mailing list
> Dbpedia-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Dbpedia-discussion mailing list
Dbpedia-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion