We are creating our Shex definition files checking that some IRIs are of a given type. There is no problem with our generated code but sometimes we get files generated using Protege and most of the individuals are of type X
plus owl:NamedIndividual
, making our validation fail because now a given resource has 2 assertions of type rdf:type
.
Adding owl:NamedIndividual
to all shape checks seems like polluting the Shape definition, so how would you allow extra properties that do not conflict with your shape definition?
In Shex, by default the triple constraints are closed which means that a shape like:
:Shape {
rdf:type [ :X ]
}
means that a node that conforms to :Shape
must have exactly one rdf:type
declaration whose value is :X
.
If you want to allow extra values for the rdf:type
declaration, you can express it with the keyword EXTRA
as:
:Shape EXTRA rdf:type {
rdf:type [ :X ]
}
The meaning now is that a conforming node must have rdf:type :X
and can have zero or mode values for rdf:type
.
Notice that the previous example could be defined as:
:Shape EXTRA a {
a [ :X ]
}
In the particular case that you only want to allow an extra rdf:type
with value owl:NamedIndividual
you could also define it as:
:Shape {
a [:X ] ;
a [ owl:NamedIndividual] ;
}
or as:
:Shape {
a [:X owl:NamedIndividual]{2} ;
}