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

Weird RDF list returned as validation result focusNode #53

Open
tpluscode opened this issue Mar 30, 2021 · 2 comments
Open

Weird RDF list returned as validation result focusNode #53

tpluscode opened this issue Mar 30, 2021 · 2 comments

Comments

@tpluscode
Copy link
Collaborator

tpluscode commented Mar 30, 2021

I don't understand but there seems to be a bug in the validation results. Here's an example shapes graph:

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <http://schema.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .

@prefix ex: <http://example.com/> .
@prefix lexvo: <http://lexvo.org/id/iso639-1/> .

ex:PersonShape
  a sh:Shape ;
  sh:targetClass schema:Person ;
  rdfs:label "Person" ;
  sh:property 
                 ex:KnowsProperty ,
                 ex:AgeProperty ,
                 ex:GenderProperty ,
                 ex:SpokenLanguagesProperty ;
.

ex:KnowsProperty
  sh:path schema:knows ;
  sh:class schema:Person ;
.

ex:AgeProperty
  sh:path schema:age ;
  sh:name "Age" ;
  sh:datatype xsd:integer ;
  sh:maxCount 1 ;
  sh:defaultValue 21 ;
  sh:order 2 ;
  sh:minInclusive 18 ;
.

ex:GenderProperty
  sh:path foaf:gender ;
  sh:name "Gender" ;
  sh:in (
    "Male" "Female" "Other" "Prefer not to tell"
  ) ;
  sh:maxCount 1 ;
  sh:order 3 ;
  sh:message "Please select a valid gender" ;
.

ex:SpokenLanguagesProperty
  sh:path vcard:language ;
  sh:name "Spoken languages" ;
  sh:nodeKind sh:IRI ;
  sh:in (
    lexvo:en lexvo:de lexvo:fr lexvo:pl lexvo:es
  ) ;
  sh:order 5 ;
  sh:minCount 1 ;
.


lexvo:en rdfs:label "English" .
lexvo:de rdfs:label "German" .
lexvo:fr rdfs:label "French" .
lexvo:pl rdfs:label "Polish" .
lexvo:es rdfs:label "Spanish" .

and data graph

{
  "@context": {
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "schema": "http://schema.org/",
    "foaf": "http://xmlns.com/foaf/0.1/",
    "vcard": "http://www.w3.org/2006/vcard/ns#"
  },
  "@graph": [
    {
      "@id": "http://example.com/John_Doe",
      "@type": "schema:Person",
      "schema:age": {
        "@type": "xsd:integer",
        "@value": "17"
      },
      "schema:knows": [
        {
          "@id": "http://example.com/Jane_Doe",
          "@type": "schema:Person",
          "schema:name": "Janet"
        },
        {
          "@type": "schema:Person"
        },
        {
          "@type": "schema:Person"
        },
        {
          "@type": "schema:Person"
        }
      ],
      "schema:name": "John Doe",
      "foaf:gender": "Malee"
    }
  ]
}

When validated together, they return a bunch of results, some of which have the sh:focusNode looking like

[ a sh:ValidationResult ;
    sh:focusNode ( "Male" "Female" "Other" "Prefer not to tell" ) ;
    sh:resultMessage "Less than 1 values" ;
    sh:resultPath <http://www.w3.org/2006/vcard/ns#language> ;
    sh:resultSeverity sh:Violation ;
    sh:sourceConstraintComponent sh:MinCountConstraintComponent ;
    sh:sourceShape <http://example.com/SpokenLanguagesProperty> ],

What's with the list? It is by no means the "focus node that has caused the result" but also not completely random, given that it's clearly the sh:in list from another field.

Is this blank nodes IDs clashing?

@martinmaillard
Copy link
Contributor

I could not reproduce that. The blank node clash hypothesis seems very likely to me. Are you using the same factory for the data and shapes datasets? Can you maybe provide a code sample?

@tpluscode
Copy link
Collaborator Author

Yes, it definitely if the shapes and data graphs getting mixed up and if they have blank nodes with same label, it looks as though they are used in place of one another. Here's a minimal example: https://runkit.com/embed/yxnja9rhg077 (run with node 13+)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants