Skip to content

Commit

Permalink
refactor: drop schema:value
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Oct 29, 2024
1 parent 7c2e6db commit 9f97da0
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 36 deletions.
7 changes: 4 additions & 3 deletions meta/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ A type of [annotation](#annotation) which can be used to express a limit or targ
a cube:MeasureDimension ;
meta:annotation [
a meta:Limit ;
schema:value 95 ;
schema:maxValue 95 ;
schema:name "Target 2020" ;
meta:annotationContext [
sh:path ex:year ;
Expand All @@ -53,7 +53,7 @@ A type of [annotation](#annotation) which can be used to express a limit or targ

</aside>

`schema:minValue` and `schema:maxValue` can be used to express a range of limit values.
`schema:minValue` and `schema:maxValue` can be used together.

## Properties

Expand All @@ -65,7 +65,8 @@ To express that the dimension provides a specific _kind_ of data which is necess
<aside class='example'>

```turtle
@prefix meta: <https://cube.link/meta/>
@prefix schema: <http://schema.org/> .
@prefix meta: <https://cube.link/meta/> .
<dimension> meta:dataKind [ a schema:GeoCoordinates ].
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
meta:annotation
[
a meta:Limit ;
schema:value 97 ;
schema:maxValue 97 ;
schema:name "Target 2020+" ;
meta:annotationContext
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
meta:annotation
[
a meta:Limit ;
schema:value 95 ;
schema:minValue 95 ;
meta:annotationContext
[
sh:path <non-dimension> ;
Expand All @@ -59,7 +59,7 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
] ,
[
a meta:Limit ;
schema:value 95 ;
schema:maxValue 95 ;
meta:annotationContext
[
sh:path <station> ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _:report a sh:ValidationReport ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:XoneConstraintComponent ;
sh:sourceShape [
sh:path _:b710 ;
sh:path _:b707 ;
sh:xone (
[
sh:class cube:KeyDimension ;
Expand All @@ -36,11 +36,11 @@ _:report a sh:ValidationReport ;
] ;
sh:focusNode _:b7 ;
sh:value _:b9 ;
sh:resultPath _:b710 ;
sh:resultPath _:b707 ;
] ;
sh:conforms false .

_:b710 rdf:first sh:path ;
_:b707 rdf:first sh:path ;
rdf:rest (
[
sh:inversePath sh:path ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ _:report a sh:ValidationReport ;
sh:result [
rdf:type sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:XoneConstraintComponent ;
sh:sourceShape <https://cube.link/shape/standalone-constraint-constraint#AnnotationValue> ;
sh:sourceConstraintComponent sh:MinCountConstraintComponent ;
sh:sourceShape [
sh:path _:b690 ;
sh:minCount 1 ;
] ;
sh:focusNode _:b4 ;
sh:value _:b4 ;
sh:resultMessage "annotation must have exactly one schema:value or a combination of schema:minValue and schema:maxValue" ;
sh:resultPath _:b690 ;
sh:resultMessage "Less than 1 values" ;
] ;
sh:conforms false .

_:b690 sh:alternativePath (
schema:minValue
schema:maxValue
) .
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
meta:annotation
[
a meta:Limit ;
schema:value 97 ;
schema:maxValue 97 ;
schema:name "Mixed target" ;
meta:annotationContext
[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
PREFIX ex: <http://example.org/>
PREFIX dcterms: <http://purl.org/dc/terms/>
@prefix relation: <https://cube.link/relation/> .
@prefix meta: <https://cube.link/meta/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix cube: <https://cube.link/> .
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix schema: <http://schema.org/> .
@base <https://example.org/> .

<cube> a cube:Cube ;
cube:observationConstraint <shape> ;
cube:observationSet <observationSet> .

<observationSet> cube:observation <observationA> .

<observationA> a cube:Observation ;
cube:observedBy <observer> ;
<measure> 4.9 ;
<year> <https://ld.admin.ch/time/year/2020> ;
.

<shape> a cube:Constraint ;
sh:targetClass cube:Observation ;
sh:closed true ;
sh:property
[
sh:path rdf:type ;
sh:nodeKind sh:IRI ;
sh:minCount 1 ;
sh:maxCount 1
] ;
sh:property
[
sh:path cube:observedBy ; ;
sh:nodeKind sh:IRI ;
sh:minCount 1 ;
sh:maxCount 1
] ;
sh:property
[
a cube:MeasureDimension ;
sh:datatype xsd:decimal ;
sh:path <measure> ;
schema:name "measure" ;
sh:minCount 1 ;
sh:maxCount 1 ;
meta:annotation
[
a meta:Limit ;
schema:name "Target 2020+" ;
schema:minValue 10 ;
schema:minValue 20 ;
meta:annotationContext
[
sh:path <year> ;
sh:minInclusive <https://ld.admin.ch/time/year/2020> ;
] ;
],
[
a meta:Limit ;
schema:name "Target 2025+" ;
schema:maxValue 10 ;
schema:maxValue 20 ;
meta:annotationContext
[
sh:path <year> ;
sh:minInclusive <https://ld.admin.ch/time/year/2025> ;
] ;
] ;
] ;
sh:property
[
a cube:KeyDimension ;
sh:path <year> ;
schema:name "year" ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:nodeKind sh:IRI ;
] ;
sh:property
[
a cube:KeyDimension ;
sh:path <station> ;
schema:name "station" ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:nodeKind sh:IRI ;
] ;
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix schema: <http://schema.org/> .
@prefix cube: <https://cube.link/> .

_:report a sh:ValidationReport ;
sh:result [
rdf:type sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MaxCountConstraintComponent ;
sh:sourceShape [
sh:path schema:minValue ;
sh:maxCount 1 ;
] ;
sh:focusNode _:b4 ;
sh:resultPath schema:minValue ;
sh:resultMessage "More than 1 values" ;
], [
rdf:type sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MaxCountConstraintComponent ;
sh:sourceShape [
sh:path schema:maxValue ;
sh:maxCount 1 ;
] ;
sh:focusNode _:b6 ;
sh:resultPath schema:maxValue ;
sh:resultMessage "More than 1 values" ;
] ;
sh:conforms false .
4 changes: 2 additions & 2 deletions test/standalone-constraint-constraint/valid.annotation.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
meta:annotation
[
a meta:Limit ;
schema:value 95 ;
schema:maxValue 95 ;
schema:name "Target 2020" ;
meta:annotationContext
[
Expand All @@ -60,7 +60,7 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
] ,
[
a meta:Limit ;
schema:value 97 ;
schema:maxValue 97 ;
schema:name "Target 2025+" ;
meta:annotationContext
[
Expand Down
34 changes: 14 additions & 20 deletions validation/standalone-constraint-constraint.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,20 @@
:AnnotationValue
a sh:NodeShape ;
sh:targetObjectsOf meta:annotation ;
sh:message "annotation must have exactly one schema:value or a combination of schema:minValue and schema:maxValue" ;
sh:xone
(
[
sh:property
[
sh:path schema:value ;
sh:minCount 1 ;
sh:maxCount 1 ;
] ;
]
[
sh:property
[
sh:path [ sh:alternativePath ( schema:minValue schema:maxValue ) ] ;
sh:minCount 1 ;
sh:maxCount 2 ;
] ;
]
) ;
sh:message "annotation must have at most one min value and one max value" ;
sh:property
[
sh:path [ sh:alternativePath ( schema:minValue schema:maxValue ) ] ;
sh:minCount 1 ;
] ,
[
sh:path schema:minValue ;
sh:maxCount 1 ;
] ,
[
sh:path schema:maxValue ;
sh:maxCount 1 ;
] ;
.

:AnnotationContextDimensionType
Expand Down

0 comments on commit 9f97da0

Please sign in to comment.