eclipse-rdf4j / rdf4j

Eclipse RDF4J: scalable RDF for Java
https://rdf4j.org/
BSD 3-Clause "New" or "Revised" License
359 stars 161 forks source link

SHACL: Support for sh:and #1247

Closed hmottestad closed 3 years ago

hmottestad commented 5 years ago

Support sh:and

https://www.w3.org/TR/shacl/#AndConstraintComponent

Also support implicit sh:and:

ex:PersonShape
    a sh:NodeShape  ;
    sh:targetClass ex:Person ;
    sh:property [
                sh:or (
                    [
                    sh:path ex:iriOrMinLength5String ;
                      sh:nodeKind sh:IRI ;
                    ]
                    [
                    sh:path ex:iriOrMinLength5String ;
                      sh:minLength 100 ;
                      sh:nodeKind sh:Literal
                    ]
                  ) ;
        ] .

Note the implicit sh:and between minLenght 100 and nodeKind sh:Literal.

hmottestad commented 5 years ago

Implicit AND is supported

hmottestad commented 5 years ago

Lots of nice little curveballs in the shacl spec. Mixing node-shape and property-shapes.

ex:SuperShape
    a sh:NodeShape ;
    sh:property [
        sh:path ex:property ;
        sh:minCount 1 ;
    ] .

ex:ExampleAndShape
    a sh:NodeShape ;
    sh:targetNode ex:ValidInstance, ex:InvalidInstance ;
    sh:and (
        ex:SuperShape
        [
            sh:path ex:property ;
            sh:maxCount 1 ;
        ]
    ) .

Kinda makes me wonder how the following works:

ex:SuperShape
    a sh:NodeShape ;
        sh:targetClass ex:ExampleClass ; #########
    sh:property [
        sh:path ex:property ;
        sh:minCount 1 ;
    ] .

ex:ExampleAndShape
    a sh:NodeShape ;
    sh:targetNode ex:ValidInstance, ex:InvalidInstance ;
    sh:and (
        ex:SuperShape
        [
            sh:path ex:property ;
            sh:maxCount 1 ;
        ]
    ) .
hmottestad commented 5 years ago

Basic sh:and is now supported.