lunisolar / LNKD.tech-Editor

Editor for Turtle (Terse RDF Triple Language, TTL) files. This is a plugin for IntelliJ IDEA, IDEA Community Edition and others IDE environments based on IntelliJ Platform (also described here)
https://plugins.jetbrains.com/plugin/12802-lnkd-tech-editor
4 stars 0 forks source link

Weird sh:path, sh:datatype and sh:class validations #43

Closed natan-cox-cognizone closed 1 year ago

natan-cox-cognizone commented 2 years ago

If I have the following SHACL

@prefix :                        <https://demo.app/shacl/> .
@prefix sh:                      <http://www.w3.org/ns/shacl#>.

:MaxCountPropertyShape
    a              sh:PropertyShape ;
    sh:path        sh:maxCount ;
    sh:datatype    xsd:integer ;
    sh:maxCount    1 ;
    sh:nodeKind    sh:Literal ;
    sh:name        "Max Count" .

Then I get

image

and also

image

I am a bit confused why these are errors?

jak-ub commented 1 year ago

Could you include also :PathPropertyShape or :DatatypePropertyShape. Because the popups show that shapes that are generating the violations are those two, not the :MaxXountPropertyShape.

From the popups I would expect that for example :PathPropertyShape looks in minimal form like:

:PathPropertyShape 
    sh:path        sh:path;
    sh:nodeKind    sh:Literal ;

Those two statements does not even need to be in one file. If you have for example :PathPropertyShape in two different files, they will still work as one (if the full IRI is exactly the same).

If I remember correctly (and this is specific to the plugin, not SHACL in general):

  1. Shapes are read from the whole project. (union graph)
  2. Focus nodes are taken from one single file being analyzed in IDE.
  3. Then data triples are taken from whole project. (union graph) .

at 3. So for example sh:maxCount might show issue that there are to many objects for a property even if those are in two separate files (with the exact same subject and predicate).

The points 1. and 3. where arbitrary decision, that this is how the plugin will work. But that could be changed - e.g. project option might be implemented to switch between graph union and single file (let me know if this is something that will be useful for you). The point 2. Is performance dictated. In order to generate report just for one file at a time (also this is how most IDE inspections work in IntelliJ platform).

jak-ub commented 1 year ago

Short version:

natan-cox-cognizone commented 1 year ago

Maybe the example I took was not the best, since it is about the SHACL of SHACL. This

@prefix :                        <https://demo.app/shacl/> .
@prefix sh:                      <http://www.w3.org/ns/shacl#>.

:MaxCountPropertyShape
    a              sh:PropertyShape ;
    sh:path        sh:maxCount ;
    sh:datatype    xsd:integer ;
    sh:maxCount    1 ;
    sh:nodeKind    sh:Literal ;
    sh:name        "Max Count" .

is kind of similar to the SHACL of SHACL in specification document document which looks like

sh:property [
  sh:path sh:maxCount ;
  sh:datatype xsd:integer ;       [# maxCount-datatype](https://www.w3.org/TR/shacl/#syntax-rule-maxCount-datatype)
  sh:maxCount 1 ;                 [# maxCount-maxCount](https://www.w3.org/TR/shacl/#syntax-rule-maxCount-maxCount)
] ;

I am not sure what a PathPropertyShape is. Or what you are trying to achieve. I cannot find it in the SHACL ontology, nor do I see it in the SHACL specifications?!

Note: we also have the same "error" on more normal SHACL documents.

natan-cox-cognizone commented 1 year ago

A more normal example, is something like this:

image
jak-ub commented 1 year ago

"I cannot find it in the SHACL ontology, nor do I see it in the SHACL specifications?!"

It is all about the content of your project (and global graphs if you added them in the settings).

Could you do quick search in project (Scope: All Places, no filtering by file mask):

Screenshot 2022-07-27 134904

The text you should look for is from this specific place (skip the : or prefix): Screenshot 2022-07-27 135029

Let me know if you find something (also if you will find nothing at all). It will help me narrow the investigation area.

natan-cox-cognizone commented 1 year ago

Aha. Yes, we have it in one of our files. So, what are we doing wrong? It is sh:nodeKind sh:Literal which looks a bit suspicious, I guess.

And sh:datatype rdfs:Resource... Cool, thanks for the tip. I guess I misread the error message.

:PathPropertyShape
    a              sh:PropertyShape ;
    sh:path        sh:path ;
    sh:datatype    rdfs:Resource ;
    sh:maxCount    1 ;
    sh:nodeKind    sh:Literal 
.