Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHACL - Scoping of logical operators with sh:hasValue and dash:hasValueIn #2458

Closed
hmottestad opened this issue Aug 22, 2020 · 5 comments · Fixed by #2459
Closed

SHACL - Scoping of logical operators with sh:hasValue and dash:hasValueIn #2458

hmottestad opened this issue Aug 22, 2020 · 5 comments · Fixed by #2459
Assignees
Labels
🐞 bug issue is a bug 📦 SHACL affects the SHACL validator
Milestone

Comments

@hmottestad
Copy link
Contributor

hmottestad commented Aug 22, 2020

There is a scoping issue for sh:or when used node shapes vs property shapes.

@prefix ex: <http://example.com/data/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:shape1
	a sh:NodeShape ;
	sh:targetClass ex:Test ;
	sh:property [
		sh:path ex:info ; 
		sh:or ([ sh:hasValue "blue" ; ] [ sh:hasValue "green" ; ] [ sh:hasValue "red" ; ]) ;
	]  .

@prefix ex: <http://example.com/data/> .

ex:test1 a ex:Test  .

The above example fails validation in the ShaclSail, but should pass since sh:hasValue is inside a sh:nodeShape and thus each value is validated independently.

@hmottestad hmottestad added 🐞 bug issue is a bug 📦 SHACL affects the SHACL validator labels Aug 22, 2020
@hmottestad hmottestad self-assigned this Aug 22, 2020
@github-actions github-actions bot added this to 📥 Inbox in Project Progress Aug 22, 2020
@hmottestad hmottestad changed the title Scoping of sh:or Scoping of sh:or with sh:hasValue Aug 22, 2020
@hmottestad hmottestad changed the title Scoping of sh:or with sh:hasValue Scoping of sh:or with sh:hasValue and dash:hasValueIn Aug 22, 2020
hmottestad added a commit to HASMAC-AS/rdf4j that referenced this issue Aug 22, 2020
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit to HASMAC-AS/rdf4j that referenced this issue Aug 22, 2020
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
hmottestad added a commit to HASMAC-AS/rdf4j that referenced this issue Aug 22, 2020
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
@abrokenjester abrokenjester moved this from 📥 Inbox to 📋 Backlog in Project Progress Aug 23, 2020
hmottestad added a commit to HASMAC-AS/rdf4j that referenced this issue Aug 29, 2020
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
@abrokenjester
Copy link
Contributor

I'm not sure I understand the example. Why should this succeed? The contraint appears to expresss that every instance of test must have a value for ex:info that is either blue, green or, red. Why should a shape that doesn't have any value for that property be valid?

@hmottestad
Copy link
Contributor Author

The definition for sh:and is "for every value" so if there are no values then it should succeed. Further more, each shape inside the sh:and is a node shape. So we are actually saying that each value for sh:info should be "red" and "blue" and ...

It took me a while to understand it. It's fairly counter intuitive.

@abrokenjester
Copy link
Contributor

...but the example is an sh:or, not an sh:and.... I'm confused.

@hmottestad
Copy link
Contributor Author

I'll update the title. The definition sh:and and sh:or are the same wrt. how they operate if there are not elements and how they operate on value nodes vs. targets.

@hmottestad hmottestad changed the title Scoping of sh:or with sh:hasValue and dash:hasValueIn SHACL - Scoping of logical operators with sh:hasValue and dash:hasValueIn Aug 31, 2020
@rdstn
Copy link
Contributor

rdstn commented Sep 2, 2020

If I'm getting this correctly, the way to retain the old behaviour for target shapes is to use paths?

So, for example, if I want this Shape to target people named Aerith or Bob, and not to match on null names, I'd do:

rsx:targetShape [
    sh:or (
        [ sh:path rdfs:name ; sh:hasValue "Aerith" ]
        [ sh:path rdfs:name ; sh:hasValue "Bob" ]
    ) ; ] ;

Whereas if I want to match null names, I'd go for:

rsx:targetShape [
    dash:hasValueIn ( "Aerith", "Bob" )
]

That one is hard to wrap one's head around, maybe you'll need some documentation pointing out how it works. Not that such documentation wouldn't be better off located in the SHACL spec.

hmottestad added a commit to HASMAC-AS/rdf4j that referenced this issue Sep 12, 2020
hmottestad added a commit to HASMAC-AS/rdf4j that referenced this issue Sep 12, 2020
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
@abrokenjester abrokenjester added this to the 3.4.1 milestone Sep 14, 2020
@abrokenjester abrokenjester moved this from 📋 Backlog to 🚧 In progress in Project Progress Sep 14, 2020
Project Progress automation moved this from 🚧 In progress to 🥳 Done Sep 14, 2020
hmottestad added a commit that referenced this issue Sep 14, 2020
* #2458 initial test cases

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>

* more test cases

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>

* GH-2458 initial fix

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>

* GH-2458 better fix

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>

* more passing tests

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>

* GH-2458 all tests pass

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>

* fixed based on review

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>

* GH-2458 added some more test cases and fixed them

Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug 📦 SHACL affects the SHACL validator
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants