- From: Holger Knublauch <holger@topquadrant.com>
- Date: Fri, 21 Jun 2019 10:44:58 +1000
- To: public-shacl@w3.org
Hi Samson, I assume you want to apply some shapes to the class resources themselves, not the instances of those classes. Correct me if I am wrong, with an example maybe? SHACL Core only defines the simple cases such as sh:targetClass, and you could theoretically enumerate the individual classes via sh:targetNode, yet this is not elegant and wouldn't dynamically discover other subclasses. Therefore, for more complex targets you'd need to resort to custom targets. These are part of a separate document "SHACL Advanced Features" and add the ability to use any SPARQL query to select the target nodes: https://www.w3.org/TR/shacl-af/#targets This mechanism (which is for example implemented by the open source SHACL API and TopBraid tools). I didn't test this, but the following illustrates the idea: ex:SubClassesShape a sh:NodeShape ; sh:target [ a sh:SPARQLTarget ; sh:prefixes ex: ; sh:select """ SELECT ?this WHERE { ?this rdfs:subClassOf+ ex:ParentClass . } """ ; ] ; The above example would apply ex:SubClassesShape to all (transitive) subclasses of ex:ParentClass, e.g. it would validate ex:MySubClassOfParentClass itself (not its instances). This pattern can be generalized into a SPARQL-based Target Type, so that the syntax could become: ex:SubClassesShape a sh:NodeShape ; sh:target [ a ex:SubClassesOfClassTarget ; ex:class ex:ParentClass ; ] ; You'd just need to declare this target type once and then can reuse it for any use case. If you need help declaring this correctly, let me know. As a bit of background, earlier versions of SHACL had this feature in the main document, under SHACL-SPARQL, but we essentially ran out of time and had to move some advanced features into the separate document. HTH and regards to Stanford, Holger On 21/06/2019 10:23, Samson Tu wrote: > Hi, > > This is a newbie question, though I couldn’t find an answer in the SHACL spec or the mailing list archive. > > I would like to specify shapes that subclasses of a specific class should satisfy. SHACL’s target declaration mechanisms don’t seem to allow that that kind of specification. > > I know that I can use OWL’s punning feature to treat the classes as if they were individuals (by making the class IRIs instances of another class), but I am hoping that I don’t need to do that. > > Any suggestions or pointers? > > Thank you. > > With best regards, > Samson
Received on Friday, 21 June 2019 00:45:25 UTC