- From: Holger Knublauch <holger@topquadrant.com>
- Date: Tue, 18 Jun 2019 19:24:27 +1000
- To: Felix Sasaki <felix@sasakiatcf.com>, public-shacl@w3.org
- Message-ID: <19015562-a22c-5fd8-bd19-44cf3c73b65c@topquadrant.com>
Here is a solution with a slightly different namespace but the same rules. Turtle file attached, TBC screenshot below. In this solution I have attached a SPARQL query to a shape that gets executed over the class itself, which then becomes $this. This has the advantage that the inner SELECT to compute the number of instances only needs to be made once. The alternative to attach it via sh:targetClass would have caused repeated computation. (Just noticed that rdf:type is not really the predicate of the triple in the validation report, so you may want to just remove the ?path result from the SELECT). HTH Holger On 18/06/2019 16:31, Felix Sasaki wrote: > Hi Holger, > > the rules applies to subjects that are instance of a given Class, e.g. > skos:Concepts. > > - Felix > > On Tue, 18 Jun 2019 at 07:55, Holger Knublauch <holger@topquadrant.com > <mailto:holger@topquadrant.com>> wrote: > > Hi Felix, > > could you clarify one thing please: how do you define "subject" in > these graphs. Does the rule apply to all subjects in the whole > data graph, including for example owl:Ontology resources or > classes, or is there a relation that you only want to apply to > sh:targetSubjectsOf <p> ? > > Holger > > > On 18/06/2019 3:31 pm, Felix Sasaki wrote: >> Hi all, >> >> I have a dataset with URIs in the subject position of triples as >> follows: >> >> <http://example.com/mydata/1> p o >> <http://example.com/mydata/2> p o >> <http://example.com/mydata/3> p o >> ... >> >> I would like to express the following constraints on all subject >> URIs: >> >> 1) The value of the URI pattern after >> "<http://example.com/mydata/" must always be an integer (in the >> example 1, 2 or 3 >> 2) The integer must be more than zero and less than the number of >> the subject URIs. That is, the third triple from the below would >> be invald: >> <http://example.com/mydata/1> p o >> <http://example.com/mydata/2> p o >> <http://example.com/mydata/4> p o # this should have been 3 >> >> I tried to express this via SPARQL constraint, but did not >> succeed. Any hints on how to express via SHACL would be nice - >> thanks. >> >> As some background for the use case: I am generating the URIs in >> an automated fashion and want to assure that the generation >> always follows the above constraints, to assure that after the >> generation no existing URI is "lost" and to assure that new URis >> follow the pattern described above. >> >> Regards, >> >> Felix >
Attachments
- text/plain attachment: felix.shapes.ttl
Received on Tuesday, 18 June 2019 09:24:59 UTC