TopQuadrant / shacl

SHACL API in Java based on Apache Jena
Apache License 2.0
217 stars 61 forks source link

shaclc grammar: nodeOr vs propertyOr #143

Closed VladimirAlexiev closed 2 years ago

VladimirAlexiev commented 2 years ago

I want to implement a constraint "Each SKOS Concept must either have skos:topConcept pointing to the nom: scheme, or have a parent that's in the same scheme". I have 2 problems:

The best I can come up with is this:

shape nomShape:concept {
  skos:topConceptOf|skos:broader  hasValue=nom:|@nomShape:parentConcept
    message="Concepts must either have skos:topConcept pointing to the nom: scheme, or have a parent that's in the same scheme"
    [1..1].
}

The first | is an alternative prop path, and the second | is propertyOr. So this says "Each concept must have topConceptOf or broader, and the value must be either the nom: scheme, or satisfy nomShape:parentConcept", and is correctly translated to this SHACL:

        sh:property          [ sh:maxCount  1 ;
                               sh:message   "Concepts must either have skos:topConcept pointing to the nom: scheme, or have a parent that's in the same scheme" ;
                               sh:minCount  1 ;
                               sh:or        ( [ sh:hasValue  nom: ]
                                              [ sh:node  nomShape:parentConcept ]
                                            ) ;
                               sh:path      [ sh:alternativePath  ( skos:topConceptOf skos:broader ) ]
                             ] ;

But it doesn't preclude the mixed-up variants skos:broader nom: or skos:topConceptOf <parentConcept>.

What I want is shaclc grammar that can produce this shacl:

sh:message   "Concepts must either have skos:topConcept pointing to the nom: scheme, or have a parent that's in the same scheme" ;
sh:or (
    [sh:property [sh:path skos:topConceptOf; sh:maxCount 1; sh:minCount 1; sh:hasValue  nom: ]]
    [sh:property [sh:path skos:broader; sh:maxCount 1; sh:minCount 1; sh:node  nomShape:parentConcept]]);

@HolgerKnublauch Can you help?

HolgerKnublauch commented 2 years ago

SHACLC support has been deleted from this TopBraid SHACL API because Jena already supports it. I suggest you create a new ticket on https://github.com/w3c/shacl/issues

VladimirAlexiev commented 2 years ago

https://github.com/w3c/shacl/issues/12