Skip to content

Turtle Format

OWLGraph accepts ontologies in Turtle (Terse RDF Triple Language) format — a compact, human-readable syntax for RDF data.

A Turtle file consists of prefix declarations and triple statements:

@prefix : <http://example.org/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
:Animal a owl:Class .
:Dog a owl:Class ; rdfs:subClassOf :Animal .

Prefixes are shorthand for long IRIs:

@prefix : <http://example.org/> . # Default namespace
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

The first four are required for most ontologies. :Animal expands to <http://example.org/Animal>.

Every statement is a subject-predicate-object triple ending with .:

:Dog a owl:Class .
:Dog rdfs:subClassOf :Animal .

Semicolon (;) — same subject, different predicate:

:Dog a owl:Class ;
rdfs:subClassOf :Animal ;
rdfs:label "Dog" .

Comma (,) — same subject and predicate, different objects:

:Dog owl:disjointWith :Cat , :Bird .
# Named class
:Animal a owl:Class .
# Subclass
:Mammal a owl:Class ;
rdfs:subClassOf :Animal .
# Disjoint classes
:Dog owl:disjointWith :Cat .
# Equivalent classes
:Canine owl:equivalentClass :Dog .
:hasOwner a owl:ObjectProperty ;
rdfs:domain :Animal ;
rdfs:range :Person .
:isOwnerOf a owl:ObjectProperty ;
owl:inverseOf :hasOwner .
:friendOf a owl:ObjectProperty , owl:SymmetricProperty .
:locatedIn a owl:ObjectProperty , owl:TransitiveProperty .
:hasParent a owl:ObjectProperty .
:hasGrandparent a owl:ObjectProperty ;
owl:propertyChainAxiom ( :hasParent :hasParent ) .
:name a owl:DatatypeProperty ;
rdfs:range xsd:string ;
a owl:FunctionalProperty .
:age a owl:DatatypeProperty ;
rdfs:range xsd:integer .
:birthDate a owl:DatatypeProperty ;
rdfs:range xsd:date .
XSD TypeDgraph TypeExample
xsd:stringstring"hello"
xsd:integerint42
xsd:floatfloat3.14
xsd:booleanbooltrue
xsd:datedatetime"2024-01-15"
xsd:dateTimedatetime"2024-01-15T10:30:00Z"
# This is a comment
:Animal a owl:Class . # Inline comment
<http://example.org/ontology> a owl:Ontology ;
rdfs:label "My Ontology" ;
owl:versionInfo "1.0" .
@prefix : <http://example.org/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
# Classes
:Animal a owl:Class .
:Mammal a owl:Class ; rdfs:subClassOf :Animal .
:Dog a owl:Class ; rdfs:subClassOf :Mammal .
:Cat a owl:Class ; rdfs:subClassOf :Mammal .
:Dog owl:disjointWith :Cat .
# Properties
:name a owl:DatatypeProperty ; rdfs:range xsd:string .
:hasOwner a owl:ObjectProperty ;
rdfs:domain :Animal ; rdfs:range :Person .
:isOwnerOf a owl:ObjectProperty ;
owl:inverseOf :hasOwner .
# Persons
:Person a owl:Class .