weso / shaclex

SHACL/ShEx implementation
http://weso.github.io/shaclex
MIT License
76 stars 17 forks source link

SHACL AND does not work #39

Open yashkhatri opened 7 years ago

yashkhatri commented 7 years ago

The following Shapes graph and Data graph exemplifies SHACL AND. It should work but, it does not.

Example Shapes Graph

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 ;
        ]
    ) . 

Example Data Graph

ex:ValidInstance
    ex:property "One" .

# Invalid: more than one property
ex:InvalidInstance
    ex:property "One" ;
    ex:property "Two" .

Example taken from source: https://www.w3.org/TR/shacl/#AndConstraintComponent

yashkhatri commented 7 years ago

@labra @darkLabra

labra commented 7 years ago

I have tested it and it works. It signals the error on ex:InvalidInstance.

If you remove the ex:InvalidInstance, it says that ex:ValidInstance conforms.

One problem, though, is that it stops as soon as there is an error and that's why it just says that there is an error in ex:InvalidInstance.

This behaviour of stopping at the first error is wrong and is something we will try to repair.

berezovskyi commented 6 years ago

Here is a minimal breaking example in Java: https://github.com/berezovskyi/Validator-Demo/tree/b1-unit-tests

Failing test: https://github.com/berezovskyi/Validator-Demo/blob/b1-unit-tests/validator-demo/src/test/java/ValidatorTest.java#L24

Shape: https://github.com/berezovskyi/Validator-Demo/blob/b1-unit-tests/validator-demo/src/test/resources/shaclAndShape.ttl

File: https://github.com/berezovskyi/Validator-Demo/blob/b1-unit-tests/validator-demo/src/test/resources/shaclAnd.ttl

Wrapper class to for library calls: https://github.com/berezovskyi/Validator-Demo/blob/b1-unit-tests/validator-demo/src/main/java/Validator.java

labra commented 6 years ago

I tried the example and it works. With the invalid shape, it signals an error, while If you uncomment the invalid shape, you can se that it is validated.

The problem, I think, is the behaviour of the whole validator which is different from SHACL in that it doesn't generate a validation report and it just stops as soon as it detects an error.

I am planning to work on this issue in the next weeks.

labra commented 6 years ago

I reopen the issue until I solve issue #38