Friends!! I am really facing this problem. Any help or suggestion will be greatly appreciated.
On Wed, Jun 25, 2014 at 3:58 PM, Dibyanshu Jaiswal <djthequ...@gmail.com> wrote: > > Hi all! > I am using Jena 2.11. > > I have an ontology setup, in a form of OntModel and backed by jena TDB. > The ontology consists of a base owl file which import 4 other owl files. > Out of these 2 owl files further import other owl files. > > > I am unable to get results using a sparql query using jena ARQ engine, > where by exactly the same query when executed in Protege 4.3 returns > appropriate results. > > Query being: > > > PREFIX un: <http://purl.oclc.org/NET/ssnx/ssn#> > PREFIX : <http://www.semanticweb.org/ontologies/2013/9/My_BASE_OWL.owl#> > PREFIX geo: <http://www.opengis.net/ont/geosparql#> > PREFIX geof: <http://www.opengis.net/def/function/geosparql/> > PREFIX sf: <http://www.opengis.net/ont/sf#> > PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> > PREFIX fn: <http://www.w3.org/2005/xpath-functions#> > PREFIX gml: <http://www.opengis.net/ont/gml#> > PREFIX j.0:<http://www.opengis.net/def/geosparql/#> > PREFIX my:<http://example.org/ApplicationSchema#> > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> > PREFIX owl: <http://www.w3.org/2002/07/owl#> > PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> > PREFIX uo: <http://purl.obolibrary.org/obo/uo#> > PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#> > PREFIX ucum: <http://purl.oclc.org/NET/muo/ucum/> > PREFIX ucumpq: <http://purl.oclc.org/NET/muo/ucum/physical-quality/> > PREFIX uomvocab: <http://purl.oclc.org/NET/muo/muo#> > > SELECT * WHERE {?UOM uomvocab:measuresQuality ucumpq:power} > > > > In my java programs, i fire the query using two methods. > 1. > public static String prefixTheQuery(String q){ > > > q ="PREFIX un: <"+AppProperties.getImportedIRI()+">\n"+ > "PREFIX : <"+AppProperties.getBaseIRI()+">\n"+ > "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n" + > "PREFIX geof: < > http://www.opengis.net/def/function/geosparql/>\n" + > "PREFIX sf: <http://www.opengis.net/ont/sf#>\n"+ > "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>\n"+ > "PREFIX fn: <http://www.w3.org/2005/xpath-functions#>\n"+ > "PREFIX gml: <http://www.opengis.net/ont/gml#>\n"+ > "PREFIX j.0:<http://www.opengis.net/def/geosparql/#>\n"+ > "PREFIX my:<http://example.org/ApplicationSchema#>\n"+ > "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns# > >\n"+ > "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"+ > "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n"+ > "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"+ > "PREFIX uo: <http://purl.obolibrary.org/obo/uo#>\n"+ > "PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#>\n"+ > "PREFIX ucum: <http://purl.oclc.org/NET/muo/ucum/>\n"+ > "PREFIX ucumpq: < > http://purl.oclc.org/NET/muo/ucum/physical-quality/>\n"+ > "PREFIX uomvocab: <http://purl.oclc.org/NET/muo/muo# > >\n"+q; > > return q; > } > > which returns the actual query string prefixed with different prefixes > being used in all the ontologies in use. > > > 2. > > public static String sparqlQuery(String sparqlQueryString){ > > String r = null; > QueryExecution qexec = null; > Query query = null; > ResultSet results = null; > ModelGenerator.getDataset().begin(ReadWrite.READ); //returns > dataset > try { > sparqlQueryString = prefixTheQuery(sparqlQueryString); > query = QueryFactory.create(sparqlQueryString) ; > qexec = > QueryExecutionFactory.create(query,ModelGenerator.getDataset()); > results = qexec.execSelect() ; > > > r = printResultsWithResultSetFormatter(results, OutputType.TEXT); > // to format output w.r.t JSON, XML,TEXT > > } catch(Exception e){ > System.out.println("Exception Occured while in QueryExecution: " ); > e.printStackTrace(); > } finally { > > qexec.close() ; > ModelGenerator.getDataset().end(); > } > > > return r; > } > > > > > Using this approach (have used this for a long time) I am unable to get > the results as expected, instead i get a blank results. > > To me the problem is that I am unable to fetch triples which have been > imported indirectly via some ontology directly imported in my base > ontology, Which is not the case when Protege is used to do the same. > > Is it so that the ontologies imported indirectly into the base model, > doest not imports the all the statements of it? > > > > > > > > *Dibyanshu Jaiswal* > Mb: +91 9038304989 > > > -- *Dibyanshu Jaiswal* Mb: +91 9038304989