- From: Irene Polikoff <irene@topquadrant.com>
- Date: Fri, 10 Apr 2020 22:51:10 -0400
- To: James Hudson <jameshudson3010@gmail.com>
- Cc: Public Shacl W3C <public-shacl@w3.org>
- Message-Id: <AF3DE23F-B31F-4DF4-8F23-70E06666906B@topquadrant.com>
Hi James, You can use SPARQL query to target anything you want - as shown in the example here https://w3c.github.io/shacl/shacl-af/#SPARQLTarget <https://w3c.github.io/shacl/shacl-af/#SPARQLTarget>. Strictly speaking, your query would not do it. It will not catch something like this: ex:R1 ex:p ex:R2 Where there are no triples with ex:R2 or ex:p as subjects. > On Apr 10, 2020, at 9:43 PM, James Hudson <jameshudson3010@gmail.com> wrote: > > Hello Irene, > > You are correct, it does not. That was an error on my part, I missed that it does not also include all the results returned by > > SELECT DISTINCT ?s > WHERE { > { > ?s ?p ?o . > FILTER NOT EXISTS { > ?s a ?c . > FILTER(?c IN (rdfs:Class, rdf:Property)) > } > } > } > > If I understand your comment correction regarding the SHACL Advanced Features, SHACL is capable of performing the validation check? > > I would love to see how that would be written... > > Regards, > James > > > On Fri, Apr 10, 2020 at 5:08 PM Irene Polikoff <irene@topquadrant.com <mailto:irene@topquadrant.com>> wrote: > How does your query find resources that have no type? > > As for ensuring that the type in either a class or a property, you could for example do the following: > > ex:Shape1 a sh:NodeShape; > sh:targetSubjectsOf rdf:type; > sh:or ( > [ > sh:path rdf:type ; > sh:class rdfs:Class ; > ] > [ > sh:path rdf:type ; > sh:class rdf:Property ; > ] > ) . > > Btw, SHACL Advanced Features supports SPARQL-based targets https://w3c.github.io/shacl/shacl-af/ <https://w3c.github.io/shacl/shacl-af/>. > >> On Apr 10, 2020, at 4:21 PM, James Hudson <jameshudson3010@gmail.com <mailto:jameshudson3010@gmail.com>> wrote: >> >> Hello, >> >> I asked a question on SO ( https://stackoverflow.com/questions/60993789/targeting-all-nodes-for-validation <https://stackoverflow.com/questions/60993789/targeting-all-nodes-for-validation> ) regarding how to verify that every node in my graph had a rdf:type and that the type was ultimately either a rdfs:Class or rdf:Property. The response I received was that it was impossible with SHACL because: >> >> The problem is that none of the four built-in target types is sufficient to reach all subject/objects regardless of predicate. >> >> I was just wondering why such a target type does not exist or if there were plans to include such a target type in the future...? >> >> I was able to do what I needed to do with SPARQL with the following query: >> >> { >> ?s rdf:type+ ?o . >> FILTER NOT EXISTS { >> ?s rdf:type+ ?c . >> FILTER(?c IN (rdfs:Class, rdf:Property)) >> } >> } >> >> but, I would have preferred to use SHACL. >> >> Regards, >> James >> >
Received on Saturday, 11 April 2020 02:51:26 UTC