w3c / data-shapes

RDF Data Shapes WG repo
87 stars 33 forks source link

maxLength-001.ttl expects support for blank nodes for sh:maxLength #150

Closed cem-okulmus closed 8 months ago

cem-okulmus commented 8 months ago

Just as a bit of context for my use case: I am currently working on a Shacl validator that aims to use SPARQL endpoints to implement the actual validation by encoding constraints into queries.

I see strange situation in the test /core/node/maxLength-001.ttl which seems incompatible with the textual definition of sh:maxLength

TEXTUAL DEFINITION For each value node v where the length (as defined by the SPARQL STRLEN function) of the string representation of v (as defined by the SPARQL str function) is greater than $maxLength, or where v is a blank node, there is a validation result with v as sh:value.

In /code/node/maxLength-001.ttl we have this blank node:

_:b34236 rdf:type ex:TestClass ;

And it should appear also in the validation report:

  sh:result [
      rdf:type sh:ValidationResult ;
      sh:focusNode _:b34236 ;
      sh:resultSeverity sh:Violation ;
      sh:sourceConstraintComponent sh:MaxLengthConstraintComponent ;
      sh:sourceShape ex:TestShape ;
      sh:value _:b34236 ;
    ] ;

The issue:

The Sparql "str" function is not defined over blank nodes and indeed many (all?) systems that serve as Sparql endpoints do not return a value for the str value of blank nodes. That is however exactly how maxLength (and minLength) are defined. So str(_:b34236) (as defined by the SPARQL str function) will not return a string. Of course, one could interpret this as returning the empty string, but then it becomes strange why it should violate a max length constraint.

HolgerKnublauch commented 8 months ago

I don't understand your concern. The textual definition explicitly states "or where v is a blank node" which is covered by that test case. In that case it doesn't matter how str() works.

cem-okulmus commented 8 months ago

Oh, sorry, seems I missed that part somehow. This is a non-issue then