If I want to say that the title of something should be an rdfs:Literal, I do this:
example:title a owl:DatatypeProperty ;
rdfs:range rdfs:Literal .
Now I want to express that something has an ordered list of titles:
example:titles a rdf:List .
How do I specify what the members of the list should be? Do I need to subclass rdf:List?
UPDATE: I would like to keep using rdf:List if possible, based on the answer by Joshua I think the following says that any rdf:List with only rdfs:Literal values is an example:ListOfLiterals, and I can then use that as a range.
@prefix entity: <http://example.com/stuff/> .
@prefix example: <http://example.com/my/term/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
example:ListOfLiterals a owl:Class ;
owl:equivalentClass [
a owl:Class ;
owl:intersectionOf (
rdf:List
[
a owl:Restriction ;
owl:allValuesFrom rdfs:Literal ;
owl:onProperty rdf:first
]
[
a owl:Restriction ;
owl:allValuesFrom example:ListOfLiterals ;
owl:onProperty rdf:rest
] )
] .
example:Book a owl:Class .
example:titles a owl:DatatypeProperty ;
rdfs:domain example:Book ;
rdfs:range example:ListOfLiterals .
entity:somebook a example:Book ;
example:titles ( "Book Title"@en "Second Book Title"@en ) .
Does that make any sense, or did I misunderstand something?
First, note that using
rdf:List
s in your OWL code means that you're going to be in OWL Full, whereas many of the reasoners are designed to work with OWL DL. You might be OK with this, and if you are, then great. If you need to remain in OWL DL, then you'll have to use your own vocabulary for lists, e.g., a classwarp:List
and propertieswarp:first
andwarp:rest
, and use those instead of their RDF counterparts.At any rate, once you've decided on your
List
class and yourfirst
andrest
properties, you can define a list typeListOfElements
that can only contain members of some classElement
with the following restriction:This means that an
ElementList
is: (i) aList
; (ii) has an value for thefirst
property that is anElement
; and (iii) has anElementList
as itsrest
, which means that the rest of the things in theList
must also beElement
s. Whatever thenil
object is should already be declared as aList
, but you may also want to include:but this isn't necessarily as important. For your case, you'd want to define a class
TitleList
in a similar fashion, and then declare the range of your property asTitleList
.Here's an example ontology that includes just defines these type of
List
class and anElementList
class (in human readable Turtle):For full generality, I've defined new a new
List
class,first
andrest
properties, and an individualnil
, but if OWL Full is OK with you, then you can just userdf:List
, etc. For completeness, here's the same ontology in RDF/XML: