There are probably a number of ways to accomplish this, depending on your implementation preferences. My advice is to use the rdf:li
special property in place of the arbitrary rdf:_nnn
, which is easier to extend. rdf:li
is equivalent to rdf:_1
, rdf:_2
in order. So the following code blocks are equivalent:
:mySeq a rdf:Seq;
rdf:_1 :foo;
rdf:_2 :bar .
:mySeq a rdf:Seq;
rdf:li :foo;
rdf:li :bar .
Note that the order in the second block is significant.
To accomplish what you are asking, you can extend rdf:li
with a new property and refine its domain/range (although these are only really meaningful to human readers, as the child property inherits the semantics of the parent):
:myItem rdfs:subPropertyOf rdf:li;
rdfs:range :typeOfElement;
rdfs:domain :mySeq .
:myItem
inherits the semantics of rdf:li
, so whatever implementatin logic you have can infer that the values of :myItem
are in some meaningful order. Next define the :mySeq
class via a property restriction:
:mySeq rdfs:subClassOf [
a owl:Restriction;
owl:onProperty :myItem;
owl:allValuesFrom :typeOfElement;].
which asserts that :mySeq
is a class of all things where the property :myItem
is explicitly used for values of :typeOfElement
. You can now create lists with :mySeq
.
To go a step further, you may define :mySeq
as the intersection of the above rule and rdf:Seq
:
:mySeq a owl:Class;
owl:equivalentClass
[ a owl:Class;
owl:intersectionOf
( rdf:Seq
[a owl:Restriction;
owl:onProperty :myItem;
owl:allValuesFrom :typeOfElement ]) ] .
Note the use owl:equivalentClass
in place of rdfs:subClassOf
. If we treat owl:equivalentClass
as symmetric and subsumed by rdfs:subClassOf
, eg:
owl:equivalentClass a owl:SymmetricProperty .
owl:equivalentClass rdfs:subPropertyOf rdfs:subClassOf .
then we can have equivalence that goes in both directions. Therefore all instances of rdf:Seq
whose values for :myItem
are of :typeOfElement
are also instances of :mySeq
. In this case you are inferring the type. So via the statement:
:x a rdf:Seq; :myItem :foo, :bar .
you may infer that :x a :mySeq
.
rdf:_n
or:myItem
, I will use in:mySeq
. My principal problem is to force:mySeq
to only use:myItem
. So I think I will have to define a sub-class ofrdf:Seq
or something like that. – Appendectomy