I have some hierarchy and I need to write them in owl syntax. All objects are classes no individuals here.
The relation between classes in each hierarchy is the same. For example "relates" is the relation in one hierarchy between all classes.
How should I define these relations? I know object property but I need something like subClassof
relation that is between all classes in the tree(protege).
Is it possible to define such a relation in owl syntax, how should I define it?
I did it but when i validated my file i got errors.
<?xml version="1.0"?>
<rdf:RDF
xmlns="http://example.org/1#"
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#"
xml:base="http://example.org/1">
<owl:Ontology rdf:about="">
<owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Created with TopBraid Composer</owl:versionInfo>
</owl:Ontology>
<owl:Class rdf:ID="a">
<haspart>
<owl:Class rdf:ID="b"/>
</haspart>
</owl:Class>
<rdf:Property rdf:ID="haspart">
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:domain rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
</rdf:Property>
</rdf:RDF>
these are errors
Untyped Object Property: http://example.org/1#haspart Untyped Class: http://www.w3.org/2000/01/rdf-schema#Class
The problem is in your definition of the hasPart
relation. To get rid of the two errors you mention, you should first of all define it to be an owl:ObjectProperty
rather than an rdf:Property
, and second of all, the domains and ranges should point to http://www.w3.org/2002/07/owl#Class
, not http://www.w3.org/2000/01/rdf-schema#Class
.
But heed the advice in the comments: don't write RDF/XML syntax by hand. It's the worst possible way to learn how to use OWL.
FWIW, here's what your ontology (with corrections) would look like in Turtle:
@prefix : <http://example.org/1#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
[] a owl:Ontology ;
owl:versionInfo "Created with TopBraid Composer"^^xsd:string .
:a a owl:Class ;
:hasPart :b .
:b a owl:Class .
:hasPart a owl:ObjectProperty ;
rdfs:domain owl:Class ;
rdfs:range owl:Class .