Search Mailing List Archives
[protege-discussion] a simple questions about owl programming
Timothy Redmond
tredmond at stanford.edu
Tue Nov 23 09:19:30 PST 2010
This is also a parser error. It is not an error in your code as far as
I can tell. The Protege 3 OWL parser is parsing a file and it is having
trouble dealing with some meta-modeling in the file. Again if you have
the ontology being parsed at this point I could provide some more
information.
-Timothy
On 11/21/2010 07:51 PM, tingyu li wrote:
> Sorry, I forgot add "file:///" in front of my string uri. and I aslo
> change file encodeing to UTF-8, and the error changed to:
>
> SEVERE: Error at parsing triple:
> http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#\u4E60\u79F0
> <http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#%5Cu4E60%5Cu79F0>
> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#alias --
> java.lang.ClassCastException:
> edu.stanford.smi.protegex.owl.model.impl.DefaultRDFProperty cannot
> be cast to edu.stanford.smi.protege.model.Cls
> at
> edu.stanford.smi.protegex.owl.jena.parser.AbstractStatefulTripleProcessor.getCls(AbstractStatefulTripleProcessor.java:106)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetType(TripleProcessorForResourceObjects.java:299)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetTypeAndCreation(TripleProcessorForResourceObjects.java:181)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:111)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:53)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessor.processTriple(TripleProcessor.java:43)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$ProtegeOWLStatementHandler.statement(ProtegeOWLParser.java:562)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.triple(XMLHandler.java:97)
> at
> com.hp.hpl.jena.rdf.arp.impl.ParserSupport.triple(ParserSupport.java:240)
> at
> com.hp.hpl.jena.rdf.arp.states.WantDescription.aPredAndObj(WantDescription.java:101)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.theObject(WantPropertyElement.java:195)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.startElement(WantPropertyElement.java:123)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startElement(XMLHandler.java:132)
> at
> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> Source)
> at
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(Unknown Source)
> at
> org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
> Source)
> at
> com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:106)
> at com.hp.hpl.jena.rdf.arp.ARP.load(ARP.java:143)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$1.invokeARP(ProtegeOWLParser.java:110)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.loadTriples(ProtegeOWLParser.java:276)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.run(ProtegeOWLParser.java:190)
> at
> edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(JenaKnowledgeBaseFactory.java:204)
> at
> edu.stanford.smi.protege.model.Project.loadDomainKB(Project.java:1369)
> at
> edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:479)
> at
> edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(OwlProjectFromUriCreator.java:62)
> at
> edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(ProtegeOWL.java:84)
> at
> com.demo.application.classAndInstanceScanning.main(classAndInstanceScanning.java:23)
>
> WARNING: Frame with wrong Java type:
> http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#alias.
> Expected: RDFSClass (or subclass), got:
> edu.stanford.smi.protegex.owl.model.impl.DefaultRDFProperty --
> AbstractStatefulTripleProcessor.getCls()
> WARNING: Error at changing Java type of:
> DefaultRDFProperty(http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#alias)
> to DefaultOWLNamedClass -- java.lang.ClassCastException:
> edu.stanford.smi.protegex.owl.model.impl.DefaultOWLNamedClass
> cannot be cast to edu.stanford.smi.protege.model.Slot
> at
> edu.stanford.smi.protege.model.framestore.Record.replaceFrameReference(Record.java:116)
> at
> edu.stanford.smi.protege.model.framestore.InMemoryFrameDb.replaceFrameKey(InMemoryFrameDb.java:286)
> at
> edu.stanford.smi.protege.model.framestore.InMemoryFrameDb.replaceFrame(InMemoryFrameDb.java:556)
> at
> edu.stanford.smi.protege.model.framestore.MergingNarrowFrameStore.replaceFrame(MergingNarrowFrameStore.java:629)
> at
> edu.stanford.smi.protegex.owl.jena.parser.AbstractStatefulTripleProcessor.swizzleFrame(AbstractStatefulTripleProcessor.java:153)
> at
> edu.stanford.smi.protegex.owl.jena.parser.AbstractStatefulTripleProcessor.getCls(AbstractStatefulTripleProcessor.java:97)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetType(TripleProcessorForResourceObjects.java:299)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetTypeAndCreation(TripleProcessorForResourceObjects.java:181)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:111)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:53)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessor.processTriple(TripleProcessor.java:43)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$ProtegeOWLStatementHandler.statement(ProtegeOWLParser.java:562)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.triple(XMLHandler.java:97)
> at
> com.hp.hpl.jena.rdf.arp.impl.ParserSupport.triple(ParserSupport.java:240)
> at
> com.hp.hpl.jena.rdf.arp.states.WantDescription.aPredAndObj(WantDescription.java:101)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.theObject(WantPropertyElement.java:195)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.startElement(WantPropertyElement.java:123)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startElement(XMLHandler.java:132)
> at
> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> Source)
> at
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(Unknown Source)
> at
> org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
> Source)
> at
> com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:106)
> at com.hp.hpl.jena.rdf.arp.ARP.load(ARP.java:143)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$1.invokeARP(ProtegeOWLParser.java:110)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.loadTriples(ProtegeOWLParser.java:276)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.run(ProtegeOWLParser.java:190)
> at
> edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(JenaKnowledgeBaseFactory.java:204)
> at
> edu.stanford.smi.protege.model.Project.loadDomainKB(Project.java:1369)
> at
> edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:479)
> at
> edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(OwlProjectFromUriCreator.java:62)
> at
> edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(ProtegeOWL.java:84)
> at
> com.demo.application.classAndInstanceScanning.main(classAndInstanceScanning.java:23)
>
> SEVERE: Error at parsing triple:
> http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#\u4EA6\u540D
> <http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#%5Cu4EA6%5Cu540D>
> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#alias --
> java.lang.ClassCastException:
> edu.stanford.smi.protegex.owl.model.impl.DefaultRDFProperty cannot
> be cast to edu.stanford.smi.protege.model.Cls
> at
> edu.stanford.smi.protegex.owl.jena.parser.AbstractStatefulTripleProcessor.getCls(AbstractStatefulTripleProcessor.java:106)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetType(TripleProcessorForResourceObjects.java:299)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetTypeAndCreation(TripleProcessorForResourceObjects.java:181)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:111)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:53)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessor.processTriple(TripleProcessor.java:43)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$ProtegeOWLStatementHandler.statement(ProtegeOWLParser.java:562)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.triple(XMLHandler.java:97)
> at
> com.hp.hpl.jena.rdf.arp.impl.ParserSupport.triple(ParserSupport.java:240)
> at
> com.hp.hpl.jena.rdf.arp.states.WantDescription.aPredAndObj(WantDescription.java:101)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.theObject(WantPropertyElement.java:195)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.startElement(WantPropertyElement.java:123)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startElement(XMLHandler.java:132)
> at
> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> Source)
> at
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(Unknown Source)
> at
> org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
> Source)
> at
> com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:106)
> at com.hp.hpl.jena.rdf.arp.ARP.load(ARP.java:143)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$1.invokeARP(ProtegeOWLParser.java:110)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.loadTriples(ProtegeOWLParser.java:276)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.run(ProtegeOWLParser.java:190)
> at
> edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(JenaKnowledgeBaseFactory.java:204)
> at
> edu.stanford.smi.protege.model.Project.loadDomainKB(Project.java:1369)
> at
> edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:479)
> at
> edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(OwlProjectFromUriCreator.java:62)
> at
> edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(ProtegeOWL.java:84)
> at
> com.demo.application.classAndInstanceScanning.main(classAndInstanceScanning.java:23)
>
> WARNING: Frame with wrong Java type:
> http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#alias.
> Expected: RDFSClass (or subclass), got:
> edu.stanford.smi.protegex.owl.model.impl.DefaultRDFProperty --
> AbstractStatefulTripleProcessor.getCls()
> WARNING: Error at changing Java type of:
> DefaultRDFProperty(http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#alias)
> to DefaultOWLNamedClass -- java.lang.ClassCastException:
> edu.stanford.smi.protegex.owl.model.impl.DefaultOWLNamedClass
> cannot be cast to edu.stanford.smi.protege.model.Slot
> at
> edu.stanford.smi.protege.model.framestore.Record.replaceFrameReference(Record.java:116)
> at
> edu.stanford.smi.protege.model.framestore.InMemoryFrameDb.replaceFrameKey(InMemoryFrameDb.java:286)
> at
> edu.stanford.smi.protege.model.framestore.InMemoryFrameDb.replaceFrame(InMemoryFrameDb.java:556)
> at
> edu.stanford.smi.protege.model.framestore.MergingNarrowFrameStore.replaceFrame(MergingNarrowFrameStore.java:629)
> at
> edu.stanford.smi.protegex.owl.jena.parser.AbstractStatefulTripleProcessor.swizzleFrame(AbstractStatefulTripleProcessor.java:153)
> at
> edu.stanford.smi.protegex.owl.jena.parser.AbstractStatefulTripleProcessor.getCls(AbstractStatefulTripleProcessor.java:97)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetType(TripleProcessorForResourceObjects.java:299)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.handleSetTypeAndCreation(TripleProcessorForResourceObjects.java:181)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects$InternalTripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:111)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessorForResourceObjects.processTriple(TripleProcessorForResourceObjects.java:53)
> at
> edu.stanford.smi.protegex.owl.jena.parser.TripleProcessor.processTriple(TripleProcessor.java:43)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$ProtegeOWLStatementHandler.statement(ProtegeOWLParser.java:562)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.triple(XMLHandler.java:97)
> at
> com.hp.hpl.jena.rdf.arp.impl.ParserSupport.triple(ParserSupport.java:240)
> at
> com.hp.hpl.jena.rdf.arp.states.WantDescription.aPredAndObj(WantDescription.java:101)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.theObject(WantPropertyElement.java:195)
> at
> com.hp.hpl.jena.rdf.arp.states.WantPropertyElement.startElement(WantPropertyElement.java:123)
> at
> com.hp.hpl.jena.rdf.arp.impl.XMLHandler.startElement(XMLHandler.java:132)
> at
> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> Source)
> at
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(Unknown Source)
> at
> org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown
> Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
> Source)
> at
> com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:106)
> at com.hp.hpl.jena.rdf.arp.ARP.load(ARP.java:143)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser$1.invokeARP(ProtegeOWLParser.java:110)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.loadTriples(ProtegeOWLParser.java:276)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.run(ProtegeOWLParser.java:190)
> at
> edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(JenaKnowledgeBaseFactory.java:204)
> at
> edu.stanford.smi.protege.model.Project.loadDomainKB(Project.java:1369)
> at
> edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:479)
> at
> edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(OwlProjectFromUriCreator.java:62)
> at
> edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(ProtegeOWL.java:84)
> at
> com.demo.application.classAndInstanceScanning.main(classAndInstanceScanning.java:23)
>
> SEVERE: Error at parsing triple:
> http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#\u4EA6\u79F
> <http://www.semanticweb.org/ontologies/2010/6/PNLN.owl#%5Cu4EA6%5Cu79F>
>
> ...
>
> 2010/11/22 tingyu li <li.hh190 at gmail.com <mailto:li.hh190 at gmail.com>>
>
> guys, I have tried a lot of methods to figure out the problems,
> but it still doesn't work, I'm pretty sure that this owl file have
> some differences, because I have read them through a lot of codes.
> and I also don't know what change I made on it. has anyone meet
> the same problem?
>
> 2010/11/20 tingyu li <li.hh190 at gmail.com <mailto:li.hh190 at gmail.com>>
>
> hi Timothy,
>
> I change an other owl files to load as the same way as son,
> but It failed, It must be caused by the owl file error, which
> I can't figure out.
> so I use the Progtege api to load the same file, the code:
>
> String uri = "locationpath";
> OWLModel owlModel =
> ProtegeOWL.createJenaOWLModelFromURI(uri);
>
> Collection classes =
> owlModel.getUserDefinedOWLNamedClasses();
>
> for (Iterator it = classes.iterator();
> it.hasNext();) {
> OWLNamedClass cls = (OWLNamedClass) it.next();
> Collection instances = cls.getInstances(false);
> System.out.println("Class " +
> cls.getBrowserText() + " (" + instances.size() + ")");
> for (Iterator jt = instances.iterator();
> jt.hasNext();) {
> OWLIndividual individual = (OWLIndividual)
> jt.next();
>
> System.out.println(" - " +
> individual.getBrowserText());
> }
> }
>
> it still failed, and the error message, which is much similar
> with the error Propervalue class made:
>
> Protege 3.4.4 Build 579, JVM 1.6.0_18-b07, memory=259M,
> Windows 7, encoding=UTF-8, language=zh, country=CN
> WARNING: Plugins directory not found:
> D:\workspace\lastprotege\plugins --
> PluginUtilities.findPluginsDirectory()
> WARNING: [Local Folder Repository] The specified file must
> be a directory.
> (D:\workspace\lastprotege\plugins\edu.stanford.smi.protegex.owl)
> -- LocalFolderRepository.update()
> SEVERE: Error at loading file
> C://Users//LiTingyu//ontologies//resultcollection.owl -- null
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.run(ProtegeOWLParser.java:174)
> at
> edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(JenaKnowledgeBaseFactory.java:204)
> at
> edu.stanford.smi.protege.model.Project.loadDomainKB(Project.java:1369)
> at
> edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:479)
> at
> edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(OwlProjectFromUriCreator.java:62)
> at
> edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(ProtegeOWL.java:84)
> at
> com.demo.application.classAndInstanceScanning.main(classAndInstanceScanning.java:22)
> Caused by: java.net.MalformedURLException: unknown protocol: c
> at java.net.URL.<init>(Unknown Source)
> at java.net.URL.<init>(Unknown Source)
> at java.net.URL.<init>(Unknown Source)
> at java.net.URI.toURL(Unknown Source)
> at
> edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.run(ProtegeOWLParser.java:172)
> ... 6 more
>
> WARNING: Error found
> edu.stanford.smi.protege.util.MessageError at 175d6ab --
> ProtegeOWL.handleErrors()
> WARNING: Error found
> edu.stanford.smi.protege.util.MessageError at 160a26f --
> ProtegeOWL.handleErrors()
> Exception in thread "main" java.lang.NullPointerException
> at
> com.demo.application.classAndInstanceScanning.main(classAndInstanceScanning.java:38)
>
>
>
> 2010/11/19 Timothy Redmond <tredmond at stanford.edu
> <mailto:tredmond at stanford.edu>>
>
> On 11/18/2010 08:53 AM, tingyu li wrote:
>> Hi Timothy,
>> it's really very in detail, and works. thank you very much.
>> And another problem is how to scan the all properties
>> that the individual has? I want get these properties and
>> values as a pair...
>
> In the Protege 3 OWL api you use
> getPossibleRDFProperties. In the Manchester OWL api,
> OWLIndividual has a method called getObjectPropertyValues.
>
> -Timothy
>
>
>
>>
>> 2010/11/19 Timothy Redmond <tredmond at stanford.edu
>> <mailto:tredmond at stanford.edu>>
>>
>>
>> The code you had essentially works except that the line
>>
>>
>>> OWLObjectProperty individual = (OWLObjectProperty) jt.next();
>>
>> is unlikely to succeed. You would expect the next
>> value to be an OWLIndividual (or a literal) not an
>> object property.
>>
>>
>>> /WARNING: Invalid frame type:
>>> DefaultOWLIndividual(http://www.semanticweb.org/ontologies/2010/0/family.owl#Jim
>>> of
>>> [DefaultOWLNamedClass(http://www.w3.org/2002/07/owl#Thing),
>>> DefaultOWLNamedClass(http://www.semanticweb.org/ontologies/2010/0/family.owl#male_family_member),
>>> DefaultRDFSNamedClass(http://www.w3.org/2002/07/owl#NamedIndividual)
>>> <http://www.w3.org/2002/07/owl#NamedIndividual%29>])
>>> -- AbstractRedirectingDispatch.getDirectOwnSlotValues()
>>> Exception in thread "main"
>>> java.lang.IllegalArgumentException: null slot/
>>
>> The first warning is weird but the exception means
>> what it says. Your owlModel does not have a hasSon
>> object property in it so objectProp is null.
>>
>>
>>> and I have take a look at owlapi, it's really more
>>> direct to handle. but after I checked these code
>>> sample on the website, I found that these codes only
>>> do some actions about class. but my target is
>>> individual.
>>
>> The "Classes and instances" example from [1] has
>> individuals. To write your code in the owl api you
>> simply put:
>>
>> OWLNamedIndividual jim = factory.getOWLNamedIndividual(":jim", prefixManager);
>> OWLObjectProperty hasSon = factory.getOWLObjectProperty(":hasSon", prefixManager);
>>
>> for (OWLIndividual son : jim.getObjectPropertyValues(hasSon, ontology)) {
>> System.out.println(" - " + son);
>> }
>>
>>
>> -Timothy
>>
>>
>> [1]http://owlapi.sourceforge.net/documentation.html
>>
>>
>> On 11/18/2010 06:55 AM, tingyu li wrote:
>>> thanks for you guys response. and I have take a look
>>> at owlapi, it's really more direct to handle. but
>>> after I checked these code sample on the website, I
>>> found that these codes only do some actions about
>>> class. but my target is individual. how to get
>>> specific individual's object property assertions is
>>> my purpose.
>>> And at the same time, I find a simple way that maybe
>>> can get this, the code is :
>>>
>>> OWLIndividual ind =
>>> owlModel.getOWLIndividual("Jim");
>>> OWLObjectProperty objectProp =
>>> owlModel.getOWLObjectProperty("hasSon");
>>> Collection values =
>>> ind.getPropertyValues(objectProp);
>>> for (Iterator jt = values.iterator();
>>> jt.hasNext();) {
>>> OWLObjectProperty individual =
>>> (OWLObjectProperty) jt.next();
>>> System.out.println(" - " +
>>> individual.getBrowserText());
>>> }
>>>
>>> but error message returned said:
>>> /WARNING: Invalid frame type:
>>> DefaultOWLIndividual(http://www.semanticweb.org/ontologies/2010/0/family.owl#Jim
>>> of
>>> [DefaultOWLNamedClass(http://www.w3.org/2002/07/owl#Thing),
>>> DefaultOWLNamedClass(http://www.semanticweb.org/ontologies/2010/0/family.owl#male_family_member),
>>> DefaultRDFSNamedClass(http://www.w3.org/2002/07/owl#NamedIndividual)
>>> <http://www.w3.org/2002/07/owl#NamedIndividual%29>])
>>> -- AbstractRedirectingDispatch.getDirectOwnSlotValues()
>>> Exception in thread "main"
>>> java.lang.IllegalArgumentException: null slot/
>>> it seems that this code just can handle the old
>>> version proj, so is there any replacement of 4.0 for
>>> the same target?
>>>
>>> In the other hand, as thomas mentioned,
>>>
>>> All of the assertion information would be
>>> retrieved in the form of different kinds of
>>> axioms that you would get for a particular
>>> individual (like Jim) by calling the method with
>>> signature:
>>>
>>> OWLOntology.getAxioms(
>>>
>>> OWLIndividual)
>>>
>>> and then filtering the results in to
>>> different classes of axiom such as
>>>
>>> OWLPropertyAssertionAxiom which supports
>>> getProperty() and getObject() to tell you
>>> which property and value it has.
>>>
>>> The usages would seem to be returned by
>>>
>>> OWLOntology.getReferencingAxioms(OWLEntity)
>>>
>>> I will appreciate if you can give me code samples
>>> about how to drive them.
>>>
>>> thx a lot!
>>>
>>> 2010/11/18 Thomas Russ <tar at isi.edu
>>> <mailto:tar at isi.edu>>
>>>
>>>
>>> On Nov 17, 2010, at 7:20 AM, tingyu li wrote:
>>>
>>> hi Thomas, thanks for your response. but I
>>> still very confused by these methods...and I
>>> have read all the samples posted on the
>>> website, but I don't find any solutions for
>>> my problems, a very similar question is
>>> about query all resources that have a
>>> certain property value. the code on website
>>> is like this:
>>> RDFProperty subClassOfProperty =
>>> owlModel.getRDFProperty(RDFSNames.Slot.SUB_CLASS_OF);
>>>
>>> OWLNamedClass owlThingClass =
>>> owlModel.getOWLThingClass();
>>> Collection results =
>>> owlModel.getRDFResourcesWithPropertyValue(subClassOfProperty,
>>> owlThingClass);
>>> System.out.println("Subclasses of owl:Thing:");
>>>
>>> for (Iterator it = results.iterator();
>>> it.hasNext();) {
>>> RDFResource resource = (RDFResource)
>>> it.next();
>>> System.out.println(" - " +
>>> resource.getBrowserText());
>>> }
>>> but, actually, there are no slot on the new
>>> version owl files. and I think RDFProperty
>>> is not very fit for my file. by the way, I
>>> use protege 4.0 to develop a owl file and
>>> save it as format: RDF/XML. the file is
>>> like this:
>>>
>>>
>>> You have to look at the class hierarchy in the
>>> Java code.
>>> OWLObjectProperty and OWLIndividual are all
>>> subclasses of RDFPropery and RDFResource, so
>>> those methods will be applicable.
>>>
>>> But if you are going to be using Protege 4, then
>>> you should be using the OWLAPI to work with the
>>> ontology rather than the Protege-OWL API. That
>>> is the underlying code that the Protege 4 code
>>> uses. OWLAPIv3 is used in Protege 4.1
>>>
>>> So the place to start for OWLAPI programming are
>>> the following documents:
>>>
>>> http://owlapi.sourceforge.net/documentation.html
>>>
>>> All of the assertion information would be
>>> retrieved in the form of different kinds of
>>> axioms that you would get for a particular
>>> individual (like Jim) by calling the method with
>>> signature:
>>>
>>> OWLOntology.getAxioms(OWLIndividual)
>>>
>>> and then filtering the results in to different
>>> classes of axiom such as
>>>
>>> OWLPropertyAssertionAxiom which supports
>>> getProperty() and getObject() to tell you which
>>> property and value it has.
>>>
>>> The usages would seem to be returned by
>>>
>>> OWLOntology.getReferencingAxioms(OWLEntity)
>>>
>>>
>>>
>>>
>>> <owl:ObjectProperty
>>> rdf:about="http://www.semanticweb.org/ontologies/2010/0/family.owl#isUncleOf">
>>> <rdfs:range
>>> rdf:resource="http://www.semanticweb.org/ontologies/2010/0/family.owl#family_member"/>
>>> <rdfs:domain
>>> rdf:resource="http://www.semanticweb.org/ontologies/2010/0/family.owl#male_family_member"/>
>>> </owl:ObjectProperty>
>>> I want get the similar result as the probem
>>> I described above. in other words, if I
>>> click Jim as the picture, I can get the
>>> result as the rigt part of the picture
>>> displayed, Usage and Property assertions:Jim
>>>
>>> thanks.
>>>
>>>
>>> _______________________________________________
>>> protege-discussion mailing list
>>> protege-discussion at lists.stanford.edu
>>> <mailto:protege-discussion at lists.stanford.edu>
>>> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>>>
>>> Instructions for unsubscribing:
>>> http://protege.stanford.edu/doc/faq.html#01a.03
>>>
>>>
>>>
>>>
>>> --
>>> Li
>>>
>>>
>>> _______________________________________________
>>> protege-discussion mailing list
>>> protege-discussion at lists.stanford.edu <mailto:protege-discussion at lists.stanford.edu>
>>> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>>>
>>> Instructions for unsubscribing:http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>
>> _______________________________________________
>> protege-discussion mailing list
>> protege-discussion at lists.stanford.edu
>> <mailto:protege-discussion at lists.stanford.edu>
>> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>>
>> Instructions for unsubscribing:
>> http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>
>>
>>
>> --
>> Li Tingyu
>> ==========================================================
>> Mobile (China): +(86) 136 6173 2368
>> Computer Science Department Shanghai JiaoTong University
>> Address: No. 800 Dongchuan Road, Shanghai China, 200240
>> ==========================================================
>>
>>
>> _______________________________________________
>> protege-discussion mailing list
>> protege-discussion at lists.stanford.edu <mailto:protege-discussion at lists.stanford.edu>
>> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>>
>> Instructions for unsubscribing:http://protege.stanford.edu/doc/faq.html#01a.03
>
>
> _______________________________________________
> protege-discussion mailing list
> protege-discussion at lists.stanford.edu
> <mailto:protege-discussion at lists.stanford.edu>
> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>
> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
>
>
>
>
> --
> Li
>
>
>
>
> --
> Li
>
>
> _______________________________________________
> protege-discussion mailing list
> protege-discussion at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-discussion/attachments/20101123/30a8015e/attachment.html>
More information about the protege-discussion
mailing list