I want to model Person
class which takes data property givenName
of type xsd:string
. How to specify length restriction of this property (say maxLength=50
) that is applicable only for Person
class? For example, I want to allow other classes to use the same property and choose different value for restriction.
Asked
Active
Viewed 3,352 times
1

Stanislav Kralin
- 11,070
- 4
- 35
- 58

Mathan G
- 23
- 1
- 3
1 Answers
4
First of all, OWL is not a constraint language. It is intended rather to define classes based on restrictions, than to set up restrictions for classes.
However, one can define anonymous “restriction-based” class and declare another class to be a subclass of this anonymous class.
In the Manchester syntax, you can write something like this:
Class: Person
SubClassOf: givenName only xsd:string[maxLength 5]
In the Functional syntax:
SubClassOf(
:Person
DataAllValuesFrom(
:givenName
DatatypeRestriction(
xsd:string
xsd:maxLength "5"^^xsd:string
)
)
)
In the Turtle syntax:
:Person rdfs:subClassOf
[ rdf:type owl:Restriction ;
owl:onProperty :givenName ;
owl:allValuesFrom
[ rdf:type rdfs:Datatype ;
owl:onDatatype xsd:string ;
owl:withRestrictions ( [ xsd:maxLength "5"^^xsd:string ] )
]
] .
The image below is the "Class description" view in Protégé:
Now suppose you declare that
Individual: He
Types: Person
Facts: givenName "Alexander"^^xsd:string
Then reasoner (e.g. HermiT) have to say that your ontology is inconsistent:

Stanislav Kralin
- 11,070
- 4
- 35
- 58
-
Great. This is very helpful. Thanks – Mathan G May 03 '17 at 20:04