juliuste opened a new issue, #3386:
URL: https://github.com/apache/jena/issues/3386

   ### Version
   
   5.5.0
   
   ### What happened?
   
   Hey everyone! First, thank you very much for maintaining this incredibly 
useful piece of software! ❤️
   
   I am using Jena's SHACL feature (via CLI) to validate data using SPARQL 
constraints. I noticed that the `sh:ValidationResult`s generated by Jena are 
missing the `sh:sourceConstraint` property, as [described here in the SHACL 
spec](https://www.w3.org/TR/shacl/#x5.3.2-mapping-of-solution-bindings-to-result-properties).
   
   I'm not sure if this is a bug or just an optional feature of SHACL that Jena 
doesn't support (yet), but I'm opening this issue just in case. Some background 
why this would be useful: Currently, there is no way to "find" the original 
SHACL definition that "caused" a `sh:ValidationResult` for SPARQL-based 
constraints. Being able to do this is necessary when SHACL definitions carry 
additional metadata besides the standard SHACL properties, which is useful in 
post-processing. For normal property constraints, this is possible, via the 
`sh:sourceShape` property on `sh:ValidationResult`s. For SPARQL-based 
constraints, however, `sh:sourceShape` can not be used, I assume that is why 
the SHACL standard adds `sh:sourceConstraint`.
   
   I'd be very thankful if you could let me know if this is indeed a bug or 
"intentional behaviour".
   
   ## Example
   
   ### `data.ttl`
   
   ```ttl
   @prefix ex: <http://example.com/ns#>.
   
   ex:A a ex:Event;
     ex:seats 100;
     ex:ticketsSold 98.
   
   ex:B a ex:Event;
     ex:seats 100;
     ex:ticketsSold 120.
   ```
   
   ### `shapes.ttl`
   
   ```ttl
   @prefix ex: <http://example.com/ns#>.
   @prefix sh: <http://www.w3.org/ns/shacl#>.
   
   ex:EventConstraint
     a sh:SPARQLConstraint;
     sh:message "Event is overbooked.";
     sh:select """
       PREFIX ex: <http://example.com/ns#>
       SELECT $this WHERE {
         $this ex:seats ?seats;
           ex:ticketsSold ?ticketsSold.
         FILTER (?seats < ?ticketsSold)
       }
       """.
   
   ex:EventShape
     a sh:NodeShape;
     sh:targetClass ex:Event;
     sh:sparql ex:EventConstraint.
   ```
   
   ### `validation.ttl`
   
   ```bash
   shacl validate --shapes shapes.ttl --data data.ttl > valdiation.ttl
   ```
   
   ```ttl
   PREFIX ex:   <http://example.com/ns#>
   PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   PREFIX sh:   <http://www.w3.org/ns/shacl#>
   PREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>
   
   [ rdf:type sh:ValidationReport;
     sh:conforms false;
     sh:result [
       rdf:type sh:ValidationResult;
       sh:focusNode                  ex:B;
       sh:resultMessage              "Event is overbooked.";
       sh:resultSeverity             sh:Violation;
       sh:sourceConstraintComponent  sh:SPARQLConstraintComponent;
       sh:sourceShape                ex:EventShape;
       sh:value                      ex:B
     ]
   ] .
   ```
   
   ### Relevant output and stacktrace
   
   ```shell
   
   ```
   
   ### Are you interested in making a pull request?
   
   None


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to