Turtle Format
OWLGraph accepts ontologies in Turtle (Terse RDF Triple Language) format — a compact, human-readable syntax for RDF data.
Basic Structure
Section titled “Basic Structure”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
Section titled “Prefixes”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>.
Triples
Section titled “Triples”Every statement is a subject-predicate-object triple ending with .:
:Dog a owl:Class .:Dog rdfs:subClassOf :Animal .Shorthand: Semicolons and Commas
Section titled “Shorthand: Semicolons and Commas”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 .Classes
Section titled “Classes”# 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 .Object Properties
Section titled “Object Properties”: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 ) .Data Properties
Section titled “Data Properties”: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 .Supported Datatypes
Section titled “Supported Datatypes”| XSD Type | Dgraph Type | Example |
|---|---|---|
xsd:string | string | "hello" |
xsd:integer | int | 42 |
xsd:float | float | 3.14 |
xsd:boolean | bool | true |
xsd:date | datetime | "2024-01-15" |
xsd:dateTime | datetime | "2024-01-15T10:30:00Z" |
Comments
Section titled “Comments”# This is a comment:Animal a owl:Class . # Inline commentCommon Patterns
Section titled “Common Patterns”Ontology Declaration
Section titled “Ontology Declaration”<http://example.org/ontology> a owl:Ontology ; rdfs:label "My Ontology" ; owl:versionInfo "1.0" .Complete Example
Section titled “Complete Example”@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 .