Hi Andy,
thanks for the reply. The proposed queries work and used to work before too. I can get the information I want in a SparQL query for either all subjects, predicates and objects or with a certain predicate specified, also using "Overall" as a condition either in filter or as object. I want to take a subject and translate it into a Java object. For that I used to get the subject via SparQL query, used the Resultset->QuerySolution->get(...).asResource() and then I used resource.getProperty(...) to access the known properties (e.g. code, preferred name etc.). Problem is that this does not work anymore ever since I loaded my ontologies into specific graphs rather than into the default graph. I can get the subject as a resource, but there are no properties accessible via listProperties() or getProperty(). I can make a SparQl query that will return all properties in separate variables and then extract those variables rather than using the getProperty() method. But I was just wondering why that used to work when both were in the default graph and why it does not work now. Here are the commands I used for the TDBloader: bin/tdbloader --graph=http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl --loc ../OntStore ../NCI_Thesaurus/Thesaurus.owl bin/tdbloader --graph=http://ec.org/ec.owl --loc ../OntStore ../Ec_Ontology.owl Regards, Wolfgang On 06/09/11 15:52, [email protected] wrote: > > Hi, > > I am using TDB and I have two ontologies, the NCI thesaurus and my own ontology (EC, created using Protege), both in RDF/XML format.Here is what I did so far: > > - Imported both ontologies into the same TDB store, using different graphs (for this example http://nci.gov and http://ec.org) > > - I can issue SparQL queries without any problems (listing the subjects, predicates and objects; restricting searches etc.), also across graphs. > > I am using a SparQl like this to get a certain subject: > > SELECT ?s > FROM NAMED http://nci.gov > FROM NAMED http://ec.org > > WHERE { > GRAPH http://nci.gov { ?s nci:Preferred_Name "Overall"^^xsd:string } > } > > And my Jena code is: > > ResultSet rs = qe.execSelect(); > while(rs.hasNext()){ > QuerySolution qs = rs.next(); > Resource subject = qs.get("s").asResource(); > StmtIterator iter = subject.listProperties(); > System.out.println(iter.hasNext()); > } > > The iterator.hasNext() call returns false and all other attempts to get a property (e.g. the preferred name property) return null. > > Earlier in my project, I loaded both ontologies into the default > graph and did not use named graphs and the approach used to work to get properties. Now listProperties() returns nothing even though a modified SparQl that returns any predicate along with the subject shows all expected properties and their URIs exactly like I am using them for getProperty() calls. > > Does anybody know why listProperties returns null when the > ontologies are loaded into two separate graphs, but it works if both are loaded into the default graph? > > Thanks in advance for any help! Is the data "Overall"^^xsd:string or "Overall" They match differently in TDB (good news, the RDF Working Group is going to fix this). Try SELECT * ... { ?s nci:Preferred_Name ?x } (you can use tdbquery) and see what the output is. Also: { ?s nci:Preferred_Name ?x . FILTER ( ?x = "Overall" ) } does a value test, not an exact term test. Andy
