AW: AW: Constraints on a property in a SKOS hierarchy

That works well, thanks, Holger.

 

A side note about editing processes and validation.

Then I edit a property and the whole graph is validated, an error like "two
instances of the property in one branch" is detected.

Then I edit a property and only the node the property is attached to is
validated, errors are only detected if the duplicate node is *above* the
node I am editing.

I guess this issue could be handled by adding another sh:property with
sh:and :

 

ex:BranchShape
    a sh:NodeShape ;
    sh:targetSubjectsOf ex:myProperty ;

sh:and (
    sh:property [
        sh:path ( [ sh:oneOrMorePath skos:broader ] ex:myProperty ) ;
        sh:maxCount 0 ;
    ] 

    sh:property [
        sh:path ( sh:inversePath ex:myProperty [ sh:oneOrMorePath
skos:broader ]) ;
        sh:maxCount 0 ;
    ]

).

Is this correct?

 

Regards

 

Felix

 

Von: Holger Knublauch <holger@topquadrant.com> 
Gesendet: Donnerstag, 23. September 2021 02:29
An: felix@sasakiatcf.com; public-shacl@w3.org
Betreff: Re: AW: Constraints on a property in a SKOS hierarchy

 

 

On 2021-09-22 10:00 pm, felix@sasakiatcf.com <mailto:felix@sasakiatcf.com>
wrote:

Thanks a lot for the example, Holger. 

 

I tried this out. Attached is 

 

1.	your shape testshape.ttl
2.	a testfile that throws an error, as expected
testdata-fails-as-exepected.ttl
3.	a testfile that does not throw an error: testdata-does-not-fail.ttl
. 

 

 

The difference between 2) and 3) is that 3) has the same value for the
ex:myProperty property. Does this make a difference?

Ah yes, that's a good point. Path expressions will eliminate duplicates, so
it will pass the maxCount constraint for this corner case!

If the hierarchy is acyclic, the following should work, doing a
skos:broader+ instead of skos:broader*. It basically means

"None of the parent concepts can have a value for ex:myProperty".

ex:BranchShape
    a sh:NodeShape ;
    sh:targetSubjectsOf ex:myProperty ;
    sh:property [
        sh:path ( [ sh:oneOrMorePath skos:broader ] ex:myProperty ) ;
        sh:maxCount 0 ;
    ] .

(This is again untested, as a dry pen-and-paper exercise)

Holger

 

I am using the TopQuadrant implementation

https://github.com/TopQuadrant/shacl/

 

Regards

 

Felix

 

Von: Holger Knublauch  <mailto:holger@topquadrant.com>
<holger@topquadrant.com> 
Gesendet: Mittwoch, 22. September 2021 02:14
An: public-shacl@w3.org <mailto:public-shacl@w3.org> 
Betreff: Re: Constraints on a property in a SKOS hierarchy

 

On 2021-09-21 6:57 pm, felix@sasakiatcf.com <mailto:felix@sasakiatcf.com>
wrote:




Dear all,

 

I would like to to the following:

 

1.	Define a property "ex:myProperty" for a skos:Concept. 
2.	In a given SKOS taxonomy, the following constraint should be
formulated: for the taxonomy, the property should appear zero or more times
in one "branch" of the taxonomy.

If you really mean zero or more times, then this wouldn't constrain
anything. My understanding is you want to say zero or one time, i.e. that
there can be at most one value per branch?




3.	 

 

The following would be a valid SKOS RDF graph:

 

example:animal a skos:Concept; ex:myProperty "some value".

example:bird a skos:Concept; skos:broader example:animal.

 

The following would be a non-valid SKOS RDF graph, since example:bird is
connected to another concept (example:animal) that already has
ex:myProperty:

 

example:animal a skos:Concept; ex:myProperty "some value".

example:bird a skos:Concept; skos:broader example:animal; ex:myProperty
"some value".

Given the above assumption, could this simply become a maxCount 1 on a path
expression skos:broader* / ex:myProperty?

Untested draft:

ex:BranchShape
    a sh:NodeShape ;
    sh:targetSubjectsOf ex:myProperty ;
    sh:property [
        sh:path ( [ sh:zeroOrMorePath skos:broader ] ex:myProperty ) ;
        sh:maxCount 1 ;
    ] .

I guess instead of the sh:targetSubjectsOf you could also simply attach this
to all skos:Concepts.

Holger

 

 

How would I formulate 2) in SHACL? 

 

Regards

 

Felix

 

Received on Thursday, 23 September 2021 07:10:33 UTC