Section 9.4 Datatype Definitions of the OWL 2 Web Ontology Language Structural Specification shows how custom datatypes can be defined, giving the following example:
a:SSN rdf:type rdfs:Datatype .
a:SSN owl:equivalentClass [
rdf:type rdfs:Datatype ;
owl:onDatatype xsd:string ;
owl:withRestrictions (
[ xsd:pattern "[0-9]{3}-[0-9]{2}-[0-9]{4}" ]
)
] .
a:hasSSN rdfs:range a:SSN .
So here we’re defining a new datatype a:SSN
by restricting the xsd:string
datatype via the xsd:pattern
facet. So far so good.
But then the specification says something I don’t understand:
The datatypes defined by datatype definition axioms … have empty lexical spaces and therefore they must not occur in literals.
Why would a:SSN
have an empty lexical space here? It was defined by constraining the value space of xsd:string
via xsd:pattern
facet. Section 4.3.4 pattern of XSD 1.1 Part 2: Datatypes says that
… pattern is a constraint on the ·value space· of a datatype which is achieved by constraining the ·lexical space· to ·literals· which match each member of a set of ·regular expressions·.
So we’re constraining the value space of xsd:string
, but we’re doing that by constraining the lexical space of xsd:string
(the set of finite-length sequences of zero or more characters … that ·match· the Char production from XML) to literals that match the regular expression. So why does the OWL spec say that the lexical space of a:SSN
is empty, rather than the the set of finite-length sequences of zero or more characters (as defined in XML) that match the regular expression [0-9]{3}-[0-9]{2}-[0-9]{4}
?
More pragmatically, the OWL spec says
… there can be no literals of datatype
a:SSN
.
So does that mean that a:SSN
cannot be used as follows?
a:Jane a:hasSSN "123-45-6789"^^a:SSN .
If so, how is one supposed to use the a:SSN
datatype? Is the idea that one should write
a:Jane a:hasSSN "123-45-6789"^^xsd:string .
and infer from the declared range of a:hasSSN
what the actual datatype is and thus whether value is valid?