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

Expressing equality between multiple paths #119

Open
mthl opened this issue Oct 7, 2019 · 4 comments
Open

Expressing equality between multiple paths #119

mthl opened this issue Oct 7, 2019 · 4 comments
Labels
SHACL 1.1 Marks items that are reasonably significant changes for a potential SHACL 1.1

Comments

@mthl
Copy link

mthl commented Oct 7, 2019

Hello,

I am trying to express the equality between two nested values inside property paths connected with one specific property http:resp, but fail to express it in SHACL as shown in the following snippets:

Here is the shapes graph I wrote

@prefix cnt: <http://www.w3.org/2011/content#>
@prefix sh: <http://www.w3.org/ns/shacl#>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@prefix ex: <http://example.com/ns#>
@prefix http: <http://www.w3.org/2011/http#>.

ex:simpleEquality a sh:PropertyShape;
    sh:path (http:resp ex:foo);
    sh:equals ex:foo.

ex:nestedEquality a sh:PropertyShape;
    sh:path (http:resp http:body cnt:isFormatOf cnt:chars);
    sh:equals (http:body cnt:isFormatOf cnt:chars).

ex:HttpEchoRequestShape a sh:NodeShape;
    sh:targetClass http:request;
    sh:property ex:simpleEquality;
    sh:property ex:nestedEquality.

and the following data graph

@prefix sh: <http://www.w3.org/ns/shacl#>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@prefix ex: <http://example.com/ns#>
@prefix http: <http://www.w3.org/2011/http#>.
@prefix cnt: <http://www.w3.org/2011/content#>

ex:req a http:request;
    ex:foo "bar";
    http:resp ex:res;
    http:body [
        a cnt:ContentAsBase64;
        cnt:isFormatOf [
            a cnt:ContentAsText;
            cnt:chars "x"
            ]].
            
ex:res a http:response;
    ex:foo "bar";
    http:body [
        a cnt:ContentAsBase64;
        cnt:isFormatOf [
            a cnt:ContentAsText;
            cnt:chars "x"
            ]].

with SHACL reference implementation (1.3.1-SNAPSHOT) I get the following report

@prefix ex:    <http://example.com/ns#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh:    <http://www.w3.org/ns/shacl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix cnt:   <http://www.w3.org/2011/content#> .
@prefix http:  <http://www.w3.org/2011/http#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

[ a            sh:ValidationReport ;
  sh:conforms  false ;
  sh:result    [ a                             sh:ValidationResult ;
                 sh:focusNode                  ex:req ;
                 sh:resultMessage              "Does not have value at property [http:body, cnt:isFormatOf, cnt:chars]" ;
                 sh:resultPath                 ( http:resp http:body cnt:isFormatOf cnt:chars ) ;
                 sh:resultSeverity             sh:Violation ;
                 sh:sourceConstraintComponent  sh:EqualsConstraintComponent ;
                 sh:sourceShape                ex:nestedEquality ;
                 sh:value                      "x"
               ]
] .

which means that it is not possible to use a SHACL property path as the range of the sh:equals property. Is there a way to express an equivalent constraint in SHACL?

Would it make sense for the sh:equals property to have the same range definition than sh:path?

Thanks

@HolgerKnublauch
Copy link
Contributor

The spec requires sh:equals to be IRI properties, i.e. paths are not supported. See "The values of sh:equals in a shape are IRIs." at

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

To express such cases you'd need to revert to SHACL-SPARQL.

@mthl
Copy link
Author

mthl commented Oct 8, 2019

Thanks for your explanation, that was my understanding of the standard too. I will try to use SHACL-SPARQL then.

I am not familiar with the W3C process for proposing an evolution of the spec, but is there a chance that the working group could consider adding this “feature”? If yes what can I do to help?

@HolgerKnublauch
Copy link
Contributor

If you are after some free-flowing discussion related to SHACL then the official place is (the mailing list of) https://www.w3.org/community/shacl/

Other than that, I believe we can leave this ticket here open as a feature request or placeholder for future consideration.

@mthl
Copy link
Author

mthl commented Oct 8, 2019

I have subscribed to the public-shacl@w3.org mailing-list, thanks.

@HolgerKnublauch HolgerKnublauch added the SHACL 1.1 Marks items that are reasonably significant changes for a potential SHACL 1.1 label Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SHACL 1.1 Marks items that are reasonably significant changes for a potential SHACL 1.1
Projects
None yet
Development

No branches or pull requests

2 participants