w3c / data-shapes

RDF Data Shapes WG repo
89 stars 33 forks source link

What happens if a focus node is a literal and the sh:Shape has sh:path? #88

Closed MiguelAraCo closed 7 years ago

MiguelAraCo commented 7 years ago

Example:

<NotTheFocusNode>
  ex:property "Hello!".

<PropertyShape>
  a sh:PropertyShape;
  sh:targetObjectsOf ex:property;
  sh:path ex:somePath.

Should the processor produce a result? And if so, what sh:sourceConstraintComponent should the result have?

HolgerKnublauch commented 7 years ago

This example would basically look for triples such as "Hello!" ex:somePath ?value, but these cannot exist. But in principle there is nothing wrong here and no results should be produced. However, if you had sh:minCount 1 it would fail with a sh:MinCountConstraintComponent violation. Does this make sense? Please close if satisfied.

MiguelAraCo commented 7 years ago

Thank you for answering so quickly.

What you just said makes me wonder if that logic applies to other places as well. For example:

<PropertyShape>
  sh:targetClass ex:TargetClass;
  sh:property [
    sh:path ex:theProperty;
    sh:uniqueLang "true"^^xsd:boolean
  ].

<FocusNode>
  a ex:TargetClass;
  ex:theProperty <SomeRandomIRI>.

In that case the restriction says that the property ex:theProperty can't have values with repeated languages. But <SomeRandomIRI> is an IRI so it can't have a language tag to begin with. In theory there's nothing wrong with that. So following the logic of your answer it shouldn't produce a result.

If this is true, then results should only be produced when the restriction is being violated directly. If the restriction can't be evaluated it won't produce a result (unless stated otherwise in the W3C recommendation).

Is this correct?

HolgerKnublauch commented 7 years ago

Yes, according to the spec there need to be at least two values with the same language tag, but in your example there is not even one. Each constraint component has individual rules.

MiguelAraCo commented 7 years ago

That makes sense. I'll follow that model in the implementation I'm working on. Thanks!