You haven't mentioned how you're constructing your ontology. If you're writing OWL by hand (e.g., with the functional syntax), then you'd do it one way; if you're writing RDF, then you'll do it another (you'd write the RDF encoding of the OWL axiom). Probably the easiest way to see how these are done is by defining the ontology using Protégé, or a similar graphical editor, and then look at the resulting code. I assume that since you used the term datetime, you're look at a data property whose values should be literals of the datatype xsd:dateTime
.
In Protégé
In Protégé you'd do something like this:
In the OWL Functional Syntax
The syntax for data property range axioms is given in 9.3.5 Data Property Range from the OWL 2 Web Ontology Language
Structural Specification and Functional-Style Syntax (Second Edition). When we save the ontology in the functional syntax, we get this:
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Ontology(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects>
Declaration(Class(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#Project>))
Declaration(DataProperty(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate>))
DataPropertyDomain(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate> <https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#Project>)
DataPropertyRange(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate> xsd:dateTime)
)
The important axiom is
DataPropertyRange(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate> xsd:dateTime)
In RDF
OWL can be serialized in RDF, and RDF can be serialized in a number of ways. Here's what that ontology looks like in the Turtle serialization of RDF, and in the RDF/XML serialization:
@prefix : <https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects>
a owl:Ontology .
:Project a owl:Class .
:dueDate a owl:DatatypeProperty ;
rdfs:domain :Project ;
rdfs:range xsd:dateTime .
The important triple, of course, is
:dueDate rdfs:range xsd:dateTime
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#"
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="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects"/>
<owl:Class rdf:about="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#Project"/>
<owl:DatatypeProperty rdf:about="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate">
<rdfs:domain rdf:resource="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#Project"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/>
</owl:DatatypeProperty>
</rdf:RDF>
It's still the same triple that's important here, but in this format it's written as:
<owl:DatatypeProperty rdf:about="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate">
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/>
</owl:DatatypeProperty>
http://www.w3.org/2001/XMLSchema#dateTime
akaxsd:dateTime
, and that's exactly what I was hoping to get! :) As a sidenote, I intentionally wrote the question this way because "most appropriate" or "best" questions are often marked off-topic on SO. – Imperative