【发布时间】:2016-07-21 14:28:45
【问题描述】:
我有 2 个本体(通过 Protege 生成)。
本体(A.owl):-
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/A#"
xml:base="http://www.semanticweb.org/ontologies/A"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/A">
<owl:imports rdf:resource="http://www.semanticweb.org/ontologies/Z"/>
</owl:Ontology>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/A#A -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#A">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/A#B"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/A#B -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#B"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
Z本体(Z.owl):-
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/Z#"
xml:base="http://www.semanticweb.org/ontologies/Z"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/Z"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Datatypes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#myName -->
<rdfs:Datatype rdf:about="http://www.semanticweb.org/ontologies/Z#myName"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#myProp -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/ontologies/Z#myProp"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#name -->
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/ontologies/Z#name">
<rdfs:range rdf:resource="http://www.semanticweb.org/ontologies/Z#myName"/>
</owl:DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#X -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/Z#X">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/Z#Y"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/Z#Y -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/Z#Y"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
我在A.owl 中导入了Z.owl。当我使用 A 本体运行 HermiT 推理器时。它会抛出 org.semanticweb.HermiT.datatypes.UnsupportedDatatypeException 异常。
异常详情:-
Exception in thread "main" org.semanticweb.HermiT.datatypes.UnsupportedDatatypeException: HermiT supports all and only the datatypes of the OWL 2 datatype map, see
http://www.w3.org/TR/owl2-syntax/#Datatype_Maps.
The datatype 'http://www.semanticweb.org/ontologies/Z#myName' is not part of the OWL 2 datatype map and
no custom datatype definition is given;
therefore, HermiT cannot handle this datatype.
我的 JAVA 代码是:-
Configuration reasonerConf = new Configuration();
reasonerConf.throwInconsistentOntologyException = false;
ReasonerFactory factory = new ReasonerFactory();
OWLReasoner reasoner = factory.createReasoner(owlOntology, reasonerConf); //Line where it throws above Exception
owlOntology 是当前工作的本体,它被 'A' 加载到 owlManager (OWLOntologyManager)。 'Z'本体也在这个owlManager中。
我试图在 protege 中运行 HermiT 推理器,但它不会在那里抛出任何异常。
【问题讨论】:
标签: java ontology protege owl-api