Validate that graph contains a node with a specific type
Closed this issue · 2 comments
MiguelAraCo commented
I'm having a hard time figuring out how to create a shape that validates the following condition:
The data graph must contain a node with a specific type (e.g. ex:Product)
My first approach was to use a shape graph like the following one:
<ContainsOneProduct>
sh:NodeShape ;
sh:targetClass ex:Product ;
sh:node
<ContainsOneProduct#graph-contains-Product> ,
<ContainsOneProduct#graph-contains-only-one-Product> ,
.
<ContainsOneProduct#graph-contains-Product>
a sh:NodeShape ;
sh:message "The graph must contain a 'ex:Project'"@en ;
sh:minCount "1"^^xsd:integer .
<ContainsOneProduct#graph-contains-only-one-Product>
a sh:NodeShape ;
sh:message "The graph mustn't contain more than one 'ex:Project'"@en ;
sh:maxCount "1"^^xsd:integer .
This can't be done because sh:NodeShape
s can't have sh:minCount
or sh:maxCount
. So what would be a way to validate this condition?
HolgerKnublauch commented
MiguelAraCo commented
Awesome, thanks!