Okay, that works as it gives me many subClassOf-properties, which is like it is defined in the ontology. Nevertheless now I am stuck with getting the actual OntProperty which should be assigned (or the value of the subClassOf-property).
Using > Property prop = iter.next().getPredicate(); > System.out.println(oc.getPropertyValue(prop).toString()); for testing purposes give some cryptic values. E.g. "-6b6b64bf:13e80b8715e:-7ff4" Is there a way to load the OntProperty out of the name? I'm not quite sure, but I expected to get anything like "&xsd;string" or the real property-name like "hasName". Is this wrong? However, thank you very much for the fast answer and your help! :-) best regards, Michael 2013/5/7 David Jordan <[email protected]> > > I ran into this same problem two weeks ago. Joshua Taylor provided me with > an answer, which I have included below. I ended up writing code similar to > the following, where I passed a Resource object > (OntModel.getResource(classURI)) representing the class to the method. > > private long listProperties(Resource resource){ > StmtIterator iter = omodel.listStatements(resource, (Property)null, > (RDFNode)null); > while( iter.hasNext() ){ > Statement stmt = iter.next(); > Property property = stmt.getPredicate(); > String pname = property.getLocalName(); > } > } > > > > > -----Original Message----- > From: Joshua TAYLOR [mailto:[email protected]] > Sent: Tuesday, April 23, 2013 3:11 PM > To: [email protected] > Subject: Re: OntClass.listDeclaredProperties > > > > On Tue, Apr 23, 2013 at 2:45 PM, David Jordan <[email protected] > <mailto:[email protected]>> wrote: > > > When I call listDeclaredProperties with a direct parameter value of > false, I get a list of properties associated with a class. But when I pass > a value of true, I don't get any values, yet there are properties directly > associated with the class. I do run this with a reasoner, using > OWL_MEM_MICRO_RULE_INF. I am using the latest TDB release. Any idea why > they are not being returned? > > > > Until now, I hadn't looked closely enough at the doc to know what > > listDeclaredProperties was supposed to return. It returns an > > iterator over "properties associated with a frame-like view of this > class", but I wasn't sure what "associated with" meant there. Looking at > the implementation in OntClassImpl, a property is associated with a class > if class is one of the property's domains. Is that the same meaning of > "associated with a class" that you're operating under? (I ask this not > because your question suggested any misunderstanding, but because I, not > having used listDeclaredProperties, assumed it might return properties in > restrictions on classes and the like, and that doesn't appear to the be the > case.) > > > > //JT > > > > -- > > Joshua Taylor, http://www.cs.rpi.edu/~tayloj/ > > > From: Michael Trosin [mailto:[email protected]] > Sent: Tuesday, May 07, 2013 3:31 PM > To: [email protected] > Subject: Query declared properties returns too much > > Hi, > I am quite new to mailing-lists, so sorry if this is not the way, how I > should start a "topic". > I have the attached ontology and I'm trying to list declared properties of > the class "Dataset" via: > OntClass ontclass = mOntModel.getOntClass(namespace + "#Dataset"); > ExtendedIterator<OntProperty> ei = ontclass.listDeclaredProperties(); > Doing it this way I get much properties, which actually aren't properties > from dataset (hasDataAnalysis, hasPublishing, ...). Loading it with direct > = true gives me the correct properties. So far so good, the problem is, > that I get now wrong results when using: > > OntClass ontclass = mOntModel.getOntClass(namespace + > "#LifecycleResource"); > ExtendedIterator<OntProperty> ei = ontclass.listDeclaredProperties(true); > Now the only property is "hasKey" (missing hasName, hasTimestamp, ...). > Is the ontology wrong defined? Or do I miss anything else? > I fixed one class and the other is no broken. I have no idea, what the > issue could be. > For any ideas many thanks in advice. > Best regards, > Michael >
