From 07592de2c8f9fb7bec6515daf6a8784bcd894382 Mon Sep 17 00:00:00 2001
From: Holger Knublauch Validation with SPARQL-based Constraint Components
+ This section extends the general mechanism + to produce validation results using of SPARQL-based constraints or + constraint components. +
+
+ Implementations that support this feature make it possible to inject so-called annotation properties
+ into the validation result nodes created for each solution produced by the SELECT queries of a
+ SPARQL-based constraint or constraint component.
+ Any such annotation property needs to be declared via a value of sh:resultAnnotation at
+ the subject of the sh:select or sh:ask triple.
+
+ The values of sh:resultAnnotation are
+ called result annotations and are either IRIs or blank nodes.
+
+ Result annotations have the following properties: +
+| Property | +Summary and Syntax Rules | +
|---|---|
sh:annotationProperty |
+
+ The property that shall be set.
+ Each result annotation has exactly one value
+ for the property sh:annotationProperty and this value is an IRI.
+ |
+
sh:annotationVarName |
+
+ The name of the SPARQL variable to take the annotation values from.
+ Each result annotation has at most 1 value
+ for the property sh:annotationVarName and this value is literal with
+ datatype xsd:string.
+ |
+
sh:annotationValue |
+ + Constant RDF terms that shall be used as default values. + | +
+ For each solution of a SELECT result set, a SHACL processor that supports annotations + walks through the declared result annotations. + The mapping from result annotations to SPARQL variables uses the following rules: +
+sh:annotationVarNamesh:annotationProperty
+ as the variable name
+ If a variable name could be determined, then the SHACL processor copies the binding for the given variable
+ as a value for the property specified using sh:annotationProperty
+ into the validation result that is being produced for the current solution.
+ If the variable has no binding in the result set solution,
+ then the values of sh:annotationValue is used, if present.
+
+ Here is an example illustrating the use of result annotations. +
+
+ex:AnnotationExample
+ a sh:NodeShape ;
+ sh:targetNode ex:ExampleResource ;
+ sh:sparql [ # _:b1
+ sh:resultAnnotation [
+ sh:annotationProperty ex:time ;
+ sh:annotationVarName "time" ;
+ ] ;
+ sh:select """
+ SELECT $this ?message ?time
+ WHERE {
+ BIND (CONCAT("The ", "message.") AS ?message) .
+ BIND (NOW() AS ?time) .
+ }
+ """ ;
+ ] .
+ + Validation produces the following validation report: +
++[ a sh:ValidationReport ; + sh:conforms false ; + sh:result [ + a sh:ValidationResult ; + sh:focusNode ex:ExampleResource ; + sh:resultMessage "The message." ; + sh:resultSeverity sh:Violation ; + sh:sourceConstraint _:b1 ; + sh:sourceConstraintComponent sh:SPARQLConstraintComponent ; + sh:sourceShape ex:AnnotationExample ; + ex:time "2015-03-27T10:58:00"^^xsd:dateTime ; # Example + ] +] .+
@@ -1659,6 +1765,7 @@
sh:SelectExpression, see Issue 288This section extends the general mechanism - to produce validation results using of SPARQL-based constraints or + to produce validation results using SPARQL-based constraints or constraint components.
- Implementations that support this feature make it possible to inject so-called annotation properties
- into the validation result nodes created for each solution produced by the SELECT queries of a
+ Implementations that support this feature make it possible to inject annotation properties
+ into the validation result nodes created for each solution produced by the SELECT queries of a
SPARQL-based constraint or constraint component.
Any such annotation property needs to be declared via a value of sh:resultAnnotation at
the subject of the sh:select or sh:ask triple.
@@ -1263,14 +1263,14 @@
- For each solution of a SELECT result set, a SHACL processor that supports annotations
+ For each solution of a SELECT result set, a SHACL processor that supports annotations
walks through the declared result annotations.
The mapping from result annotations to SPARQL variables uses the following rules:
sh:annotationVarNamesh:annotationProperty
- as the variable name
If a variable name could be determined, then the SHACL processor copies the binding for the given variable
From 4af55fe7db87f449532794daaea7cd492892377b Mon Sep 17 00:00:00 2001
From: Holger Knublauch Annotation Properties
as a value for the property specified using sh:annotationProperty
into the validation result that is being produced for the current solution.
If the variable has no binding in the result set solution,
- then the values of sh:annotationValue is used, if present.
+ then the values of sh:annotationValue are used, if present.
Here is an example illustrating the use of result annotations.
From d75cfee192b551049ac7ef43095cfab5d335f501 Mon Sep 17 00:00:00 2001
From: Alex Nelson Annotation Properties
From e5d86de9aa4dea7b2b2b2962485638a8be2e35f6 Mon Sep 17 00:00:00 2001
From: Alex Nelson sh:annotationValue
- Constant RDF terms that shall be used as default values.
+ Constant RDF terms that shall be used as default values.