Don't know. What reasoner configuration are you using?
Is there any other data in the "individuals" model? Dave On 09/09/14 08:07, huang huiliang wrote:
Thank you for your suggestion ,Dave. I modify my code as you said. Before p.addDomain(class2) ,the class2's SupClass is : http://www.xxx.org.cn/standards/publishing/ontology/cores/class1. But after p.addDomain(class2) execute ,class2's has two SupClasses. http://www.w3.org/2000/01/rdf-schema#Resource is added to class2's SupClasses. Now the question is : why would addDomain(class2) add rdfs:Resouce to class2's SupClasses. Thanks for your attention. -----邮件原件----- 发件人: Dave Reynolds [mailto:[email protected]] 发送时间: 2014年9月9日 14:51 收件人: [email protected] 主题: Re: why does the addDomain method affect the domain's SuperClass? On 09/09/14 07:40, huang huiliang wrote:I'm creating an ontology from excel files and I have some problems to make my program work. The first problem I encounter is that I can't get the right superclass .The simplest code example is below. Code begin: OntModel individuals = ModelFactory.createOntologyModel(); TreeMap<String, String> namespaces=new TreeMap<String,String>(); namespaces.put("pubo", "http://www.xxx.org.cn/standards/publishing/ontology/cores/"); individuals.setNsPrefixes(namespaces); OntClass class1=individuals.createClass(namespaces.get("pubo")+"class1"); class1.setLabel("class1", "en"); OntClass class2=individuals.createClass(namespaces.get("pubo")+"class2"); class2.setLabel("class2", "en"); class2.setSuperClass(class1); System.out.println(class2.getSuperClass().getURI()); DatatypeProperty p = individuals.createDatatypeProperty(namespaces .get("pubo") + "haha"); p.addDomain(class2); System.out.println(class2.getSuperClass().getURI()); Code end The first output is: <http://www.xxx.org.cn/standards/publishing/ontology/cores/class1> http://www.xxx.org.cn/standards/publishing/ontology/cores/class1 The second output is : http://www.w3.org/2000/01/rdf-schema#Resource I have no idea why the two output are different? Have I done something wrong? Any suggestions?Mostly likely possibility is that getSuperClass is simply picking a different random value from the set of super classes (see the javadoc). I don't know if getSuperClass is supposed to list only direct superclasses but if you are getting rdfs:Resource then probably not. Suggest using listSuperClasses(true) to find out what's going on. Dave
