From b13b364dcf7a8d0e0d3fb720ab403b1418a8975a Mon Sep 17 00:00:00 2001 From: marmolpen3 Date: Mon, 16 Nov 2026 11:56:10 +0100 Subject: [PATCH 1/3] fix: accept xsd:integer for payAmount and percentage --- docs/Requirements.md | 4 ++-- src/shapes/Shapes.ts | 17 +++++++++++++---- .../08-odrl-constraint-right-operands.ttl | 12 ++++++------ src/shapes/odrl-shapes.ttl | 12 ++++++------ test/unit/ConstraintShapes.test.ts | 14 ++++++++++++-- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/docs/Requirements.md b/docs/Requirements.md index 1829c39..44cdd0c 100644 --- a/docs/Requirements.md +++ b/docs/Requirements.md @@ -83,9 +83,9 @@ The extraction of these requirements is based on the [ODRL 2.2 information model - R69: odrl:meteredTime is only compatible with eq, lt, lteq - Violation - **New** - R70: The rightOperand for odrl:meteredTime must be an xsd:duration - Violation - **New** - R71: odrl:payAmount is only compatible with comparison operators - Violation - **New** -- R72: The rightOperand for odrl:payAmount must be an xsd:decimal - Violation - **New** +- R72: The rightOperand for odrl:payAmount must be an xsd:decimal or xsd:integer, not negative - Violation - **New** - R73: odrl:percentage is only compatible with comparison operators - Violation - **New** -- R74: The rightOperand for odrl:percentage must be an xsd:decimal between 0 and 100 - Violation - **New** +- R74: The rightOperand for odrl:percentage must be an xsd:decimal or xsd:integer between 0 and 100 - Violation - **New** - R75: odrl:product is only compatible with eq, neq, isA, isAnyOf, isNoneOf - Violation - **New** - R76: The rightOperand for odrl:product must be an IRI or a string - Warning - **New** - R77: odrl:purpose is only compatible with eq, neq, isA, isAnyOf, isNoneOf - Violation - **New** diff --git a/src/shapes/Shapes.ts b/src/shapes/Shapes.ts index e8e2405..800c9b9 100644 --- a/src/shapes/Shapes.ts +++ b/src/shapes/Shapes.ts @@ -1324,7 +1324,7 @@ export const SHAPES: string = `@prefix odrl: . a sh:NodeShape ; sh:targetClass odrl:Constraint ; sh:targetSubjectsOf odrl:leftOperand ; - sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal." ; + sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative." ; sh:severity sh:Violation ; sh:or ([ sh:not [ @@ -1333,13 +1333,18 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:datatype xsd:decimal + sh:or ([ + sh:datatype xsd:decimal + ] [ + sh:datatype xsd:integer + ]) ; + sh:minInclusive 0 ]) . a sh:NodeShape ; sh:targetClass odrl:Constraint ; sh:targetSubjectsOf odrl:leftOperand ; - sh:message "The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100." ; + sh:message "The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100." ; sh:severity sh:Violation ; sh:or ([ sh:not [ @@ -1348,7 +1353,11 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:datatype xsd:decimal ; + sh:or ([ + sh:datatype xsd:decimal + ] [ + sh:datatype xsd:integer + ]) ; sh:minInclusive 0 ; sh:maxInclusive 100 ]) . diff --git a/src/shapes/modules/08-odrl-constraint-right-operands.ttl b/src/shapes/modules/08-odrl-constraint-right-operands.ttl index 46c4793..34752a0 100644 --- a/src/shapes/modules/08-odrl-constraint-right-operands.ttl +++ b/src/shapes/modules/08-odrl-constraint-right-operands.ttl @@ -145,7 +145,7 @@ sh:message "The rightOperand of odrl:meteredTime must be an xsd:duration." . -# R72: the rightOperand of odrl:payAmount must be an xsd:decimal +# R72: the rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative :PayAmountRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -153,12 +153,12 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:payAmount ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:decimal ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ] ) ; - sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal." . + sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative." . -# R74: the rightOperand of odrl:percentage must be an xsd:decimal between 0 and 100 +# R74: the rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer between 0 and 100 :PercentageRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -166,9 +166,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:percentage ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:decimal ; sh:minInclusive 0 ; sh:maxInclusive 100 ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ; sh:maxInclusive 100 ] ) ; - sh:message "The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100." . + sh:message "The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100." . # R76: the rightOperand of odrl:product must be an IRI or a string diff --git a/src/shapes/odrl-shapes.ttl b/src/shapes/odrl-shapes.ttl index 71475fc..f2eb48a 100644 --- a/src/shapes/odrl-shapes.ttl +++ b/src/shapes/odrl-shapes.ttl @@ -1442,7 +1442,7 @@ sh:message "The rightOperand of odrl:meteredTime must be an xsd:duration." . -# R72: the rightOperand of odrl:payAmount must be an xsd:decimal +# R72: the rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative :PayAmountRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -1450,12 +1450,12 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:payAmount ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:decimal ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ] ) ; - sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal." . + sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative." . -# R74: the rightOperand of odrl:percentage must be an xsd:decimal between 0 and 100 +# R74: the rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer between 0 and 100 :PercentageRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -1463,9 +1463,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:percentage ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:decimal ; sh:minInclusive 0 ; sh:maxInclusive 100 ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ; sh:maxInclusive 100 ] ) ; - sh:message "The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100." . + sh:message "The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100." . # R76: the rightOperand of odrl:product must be an IRI or a string diff --git a/test/unit/ConstraintShapes.test.ts b/test/unit/ConstraintShapes.test.ts index d920fd7..04eb1e3 100644 --- a/test/unit/ConstraintShapes.test.ts +++ b/test/unit/ConstraintShapes.test.ts @@ -30,9 +30,9 @@ const MESSAGES = { R69: 'odrl:meteredTime must only be used with odrl:eq, odrl:lt or odrl:lteq.', R70: 'The rightOperand of odrl:meteredTime must be an xsd:duration.', R71: 'odrl:payAmount must only be used with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', - R72: 'The rightOperand of odrl:payAmount must be an xsd:decimal.', + R72: 'The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative.', R73: 'odrl:percentage must only be used with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', - R74: 'The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100.', + R74: 'The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100.', R75: 'odrl:product must only be used with odrl:eq, odrl:neq, odrl:isA, odrl:isAnyOf or odrl:isNoneOf.', R76: 'The rightOperand of odrl:product should be an IRI, a string, or a list of these.', R77: 'odrl:purpose must only be used with odrl:eq, odrl:neq, odrl:isA, odrl:isAnyOf or odrl:isNoneOf.', @@ -170,9 +170,13 @@ describe('The constraint rightOperand shapes', () => { [ 'R70', 'odrl:meteredTime', '"PT60M"^^xsd:duration' ], [ 'R72', 'odrl:payAmount', '"10.50"^^xsd:decimal' ], [ 'R72', 'odrl:payAmount', '10.5' ], + [ 'R72', 'odrl:payAmount', '10' ], + [ 'R72', 'odrl:payAmount', '0' ], [ 'R74', 'odrl:percentage', '"50"^^xsd:decimal' ], [ 'R74', 'odrl:percentage', '"0.0"^^xsd:decimal' ], [ 'R74', 'odrl:percentage', '"100.0"^^xsd:decimal' ], + [ 'R74', 'odrl:percentage', '50' ], + [ 'R74', 'odrl:percentage', '100' ], [ 'R76', 'odrl:product', ':magazine' ], [ 'R76', 'odrl:product', '"magazine"' ], [ 'R76', 'odrl:product', '( :magazine "newspaper" )' ], @@ -223,9 +227,15 @@ describe('The constraint rightOperand shapes', () => { [ 'R70', 'odrl:meteredTime', '"60"^^xsd:integer', 'Violation' ], [ 'R72', 'odrl:payAmount', '"10 EUR"', 'Violation' ], [ 'R72', 'odrl:payAmount', '"abc"^^xsd:decimal', 'Violation' ], + [ 'R72', 'odrl:payAmount', '"10.5"^^xsd:double', 'Violation' ], + [ 'R72', 'odrl:payAmount', '-10', 'Violation' ], + [ 'R72', 'odrl:payAmount', '"-0.5"^^xsd:decimal', 'Violation' ], [ 'R74', 'odrl:percentage', '"100.5"^^xsd:decimal', 'Violation' ], [ 'R74', 'odrl:percentage', '"-1"^^xsd:decimal', 'Violation' ], [ 'R74', 'odrl:percentage', '"50%"', 'Violation' ], + [ 'R74', 'odrl:percentage', '150', 'Violation' ], + [ 'R74', 'odrl:percentage', '-1', 'Violation' ], + [ 'R74', 'odrl:percentage', '"50"^^xsd:double', 'Violation' ], [ 'R76', 'odrl:product', '"5"^^xsd:integer', 'Warning' ], [ 'R76', 'odrl:product', '( :magazine "5"^^xsd:integer )', 'Warning' ], [ 'R78', 'odrl:purpose', '"5"^^xsd:integer', 'Warning' ], From adfabe37e04ce6ea4fe6ee99181d56fc59b5f07d Mon Sep 17 00:00:00 2001 From: marmolpen3 Date: Tue, 17 Nov 2026 21:08:25 +0100 Subject: [PATCH 2/3] fix: accept XSD subtypes for rightOperand datatypes and forbid negative count --- docs/Requirements.md | 8 +- src/shapes/Shapes.ts | 139 +++++++++++++----- .../08-odrl-constraint-right-operands.ttl | 118 +++++++++++---- src/shapes/odrl-shapes.ttl | 116 +++++++++++---- test/unit/ConstraintShapes.test.ts | 19 ++- 5 files changed, 296 insertions(+), 104 deletions(-) diff --git a/docs/Requirements.md b/docs/Requirements.md index 44cdd0c..3a5d529 100644 --- a/docs/Requirements.md +++ b/docs/Requirements.md @@ -56,12 +56,14 @@ The extraction of these requirements is based on the [ODRL 2.2 information model - R44: Each element of a LogicalConstraint must be a valid Constraint - Violation - [Wiki V19](https://www.w3.org/2016/poe/wiki/Validation#V19._The_values_of_every_logical_constraint_must_be_constraints) ### Constraint operator compatibility +Each XSD datatype also includes its subtypes (e.g. xsd:integer is an xsd:decimal), see https://www.w3.org/TR/xmlschema11-2/#built-in-datatypes. + - R45: odrl:absolutePosition is only compatible with eq, gt, gteq, lt, lteq, neq - Violation - **New** - R46: odrl:absoluteSpatialPosition is only compatible with comparison operators - Violation - **New** - R47: odrl:absoluteTemporalPosition is only compatible with comparison operators - Violation - **New** - R48: odrl:absoluteSize is only compatible with comparison operators - Violation - **New** - R49: odrl:count is only compatible with comparison operators - Violation - **New** -- R50: The rightOperand for odrl:count must be an xsd:integer - Violation - **New** +- R50: The rightOperand for odrl:count must be an xsd:integer, not negative - Violation - **New** - R51: odrl:dateTime is only compatible with comparison operators - Violation - **New** - R52: The rightOperand for odrl:dateTime must be xsd:date or xsd:dateTime - Violation - **New** - R53: odrl:delayPeriod is only compatible with eq, gt, gteq - Violation - **New** @@ -83,9 +85,9 @@ The extraction of these requirements is based on the [ODRL 2.2 information model - R69: odrl:meteredTime is only compatible with eq, lt, lteq - Violation - **New** - R70: The rightOperand for odrl:meteredTime must be an xsd:duration - Violation - **New** - R71: odrl:payAmount is only compatible with comparison operators - Violation - **New** -- R72: The rightOperand for odrl:payAmount must be an xsd:decimal or xsd:integer, not negative - Violation - **New** +- R72: The rightOperand for odrl:payAmount must be an xsd:decimal - Violation - **New** - R73: odrl:percentage is only compatible with comparison operators - Violation - **New** -- R74: The rightOperand for odrl:percentage must be an xsd:decimal or xsd:integer between 0 and 100 - Violation - **New** +- R74: The rightOperand for odrl:percentage must be an xsd:decimal between 0 and 100 - Violation - **New** - R75: odrl:product is only compatible with eq, neq, isA, isAnyOf, isNoneOf - Violation - **New** - R76: The rightOperand for odrl:product must be an IRI or a string - Warning - **New** - R77: odrl:purpose is only compatible with eq, neq, isA, isAnyOf, isNoneOf - Violation - **New** diff --git a/src/shapes/Shapes.ts b/src/shapes/Shapes.ts index 800c9b9..ff18bdb 100644 --- a/src/shapes/Shapes.ts +++ b/src/shapes/Shapes.ts @@ -1103,7 +1103,7 @@ export const SHAPES: string = `@prefix odrl: . a sh:NodeShape ; sh:targetClass odrl:Constraint ; sh:targetSubjectsOf odrl:leftOperand ; - sh:message "The rightOperand of odrl:count must be an xsd:integer." ; + sh:message "The rightOperand of odrl:count must be an xsd:integer, not negative." ; sh:severity sh:Violation ; sh:or ([ sh:not [ @@ -1112,7 +1112,37 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; + sh:node ; + sh:minInclusive 0 + ]) . + + a sh:NodeShape ; + sh:or ([ sh:datatype xsd:integer + ] [ + sh:datatype xsd:long + ] [ + sh:datatype xsd:int + ] [ + sh:datatype xsd:short + ] [ + sh:datatype xsd:byte + ] [ + sh:datatype xsd:nonNegativeInteger + ] [ + sh:datatype xsd:positiveInteger + ] [ + sh:datatype xsd:unsignedLong + ] [ + sh:datatype xsd:unsignedInt + ] [ + sh:datatype xsd:unsignedShort + ] [ + sh:datatype xsd:unsignedByte + ] [ + sh:datatype xsd:nonPositiveInteger + ] [ + sh:datatype xsd:negativeInteger ]) . a sh:NodeShape ; @@ -1127,11 +1157,16 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:or ([ - sh:datatype xsd:date - ] [ - sh:datatype xsd:dateTime - ]) + sh:node + ]) . + + a sh:NodeShape ; + sh:or ([ + sh:datatype xsd:date + ] [ + sh:datatype xsd:dateTime + ] [ + sh:datatype xsd:dateTimeStamp ]) . a sh:NodeShape ; @@ -1146,7 +1181,16 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; + sh:node + ]) . + + a sh:NodeShape ; + sh:or ([ sh:datatype xsd:duration + ] [ + sh:datatype xsd:dayTimeDuration + ] [ + sh:datatype xsd:yearMonthDuration ]) . a sh:NodeShape ; @@ -1164,12 +1208,35 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ] [ sh:node ]) ]) . + a sh:NodeShape ; + sh:or ([ + sh:datatype xsd:string + ] [ + sh:datatype xsd:normalizedString + ] [ + sh:datatype xsd:token + ] [ + sh:datatype xsd:language + ] [ + sh:datatype xsd:Name + ] [ + sh:datatype xsd:NCName + ] [ + sh:datatype xsd:ENTITY + ] [ + sh:datatype xsd:ID + ] [ + sh:datatype xsd:IDREF + ] [ + sh:datatype xsd:NMTOKEN + ]) . + a sh:NodeShape ; sh:property [ sh:path ([ @@ -1178,7 +1245,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ]) ] ; sh:node . @@ -1195,7 +1262,7 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:datatype xsd:duration + sh:node ]) . a sh:NodeShape ; @@ -1213,7 +1280,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ]) ]) . @@ -1232,7 +1299,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1253,7 +1320,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1272,7 +1339,7 @@ export const SHAPES: string = `@prefix odrl: . ] [ sh:path odrl:rightOperand ; sh:or ([ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1283,7 +1350,7 @@ export const SHAPES: string = `@prefix odrl: . sh:path ([ sh:zeroOrMorePath rdf:rest ] rdf:first) ; - sh:datatype xsd:string + sh:node ] ; sh:node . @@ -1300,7 +1367,7 @@ export const SHAPES: string = `@prefix odrl: . ] [ sh:path odrl:rightOperand ; sh:or ([ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1318,13 +1385,13 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:datatype xsd:duration + sh:node ]) . a sh:NodeShape ; sh:targetClass odrl:Constraint ; sh:targetSubjectsOf odrl:leftOperand ; - sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative." ; + sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal." ; sh:severity sh:Violation ; sh:or ([ sh:not [ @@ -1333,18 +1400,20 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:or ([ - sh:datatype xsd:decimal - ] [ - sh:datatype xsd:integer - ]) ; - sh:minInclusive 0 + sh:node + ]) . + + a sh:NodeShape ; + sh:or ([ + sh:datatype xsd:decimal + ] [ + sh:node ]) . a sh:NodeShape ; sh:targetClass odrl:Constraint ; sh:targetSubjectsOf odrl:leftOperand ; - sh:message "The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100." ; + sh:message "The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100." ; sh:severity sh:Violation ; sh:or ([ sh:not [ @@ -1353,11 +1422,7 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:or ([ - sh:datatype xsd:decimal - ] [ - sh:datatype xsd:integer - ]) ; + sh:node ; sh:minInclusive 0 ; sh:maxInclusive 100 ]) . @@ -1377,7 +1442,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1398,7 +1463,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1419,7 +1484,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1455,7 +1520,7 @@ export const SHAPES: string = `@prefix odrl: . sh:or ([ sh:nodeKind sh:IRI ] [ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1473,7 +1538,7 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:datatype xsd:duration + sh:node ]) . a sh:NodeShape ; @@ -1488,7 +1553,7 @@ export const SHAPES: string = `@prefix odrl: . ] ] [ sh:path odrl:rightOperand ; - sh:datatype xsd:string + sh:node ]) . a sh:NodeShape ; @@ -1504,7 +1569,7 @@ export const SHAPES: string = `@prefix odrl: . ] [ sh:path odrl:rightOperand ; sh:or ([ - sh:datatype xsd:string + sh:node ] [ sh:node ]) @@ -1523,7 +1588,7 @@ export const SHAPES: string = `@prefix odrl: . ] [ sh:path odrl:rightOperand ; sh:or ([ - sh:datatype xsd:string + sh:node ] [ sh:node ]) diff --git a/src/shapes/modules/08-odrl-constraint-right-operands.ttl b/src/shapes/modules/08-odrl-constraint-right-operands.ttl index 34752a0..0237786 100644 --- a/src/shapes/modules/08-odrl-constraint-right-operands.ttl +++ b/src/shapes/modules/08-odrl-constraint-right-operands.ttl @@ -2,7 +2,7 @@ # RightOperand datatype per leftOperand ################################################# -# R50: the rightOperand of odrl:count must be an xsd:integer +# R50: the rightOperand of odrl:count must be an xsd:integer, not negative :CountRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -10,9 +10,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:count ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:integer ] + [ sh:path odrl:rightOperand ; sh:node :IntegerShape ; sh:minInclusive 0 ] ) ; - sh:message "The rightOperand of odrl:count must be an xsd:integer." . + sh:message "The rightOperand of odrl:count must be an xsd:integer, not negative." . # R52: the rightOperand of odrl:dateTime must be an xsd:date or xsd:dateTime @@ -23,7 +23,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:dateTime ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:date ] [ sh:datatype xsd:dateTime ] ) ] + [ sh:path odrl:rightOperand ; sh:node :DateTimeShape ] ) ; sh:message "The rightOperand of odrl:dateTime must be an xsd:date or xsd:dateTime." . @@ -36,7 +36,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:delayPeriod ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:delayPeriod must be an xsd:duration." . @@ -49,7 +49,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:deliveryChannel ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:deliveryChannel should be an IRI, a string, or a list of these." . @@ -62,7 +62,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:elapsedTime ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:elapsedTime must be an xsd:duration." . @@ -75,7 +75,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:event ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] ) ] ) ; sh:message "The rightOperand of odrl:event should be an IRI or a string." . @@ -88,7 +88,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:fileFormat ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:fileFormat should be an IRI, a string, or a list of these." . @@ -101,7 +101,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:industry ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:industry should be an IRI, a string, or a list of these." . @@ -114,7 +114,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:language ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:language should be a string or a list of strings." . @@ -127,7 +127,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:media ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:media should be a string or a list of strings." . @@ -140,12 +140,12 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:meteredTime ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:meteredTime must be an xsd:duration." . -# R72: the rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative +# R72: the rightOperand of odrl:payAmount must be an xsd:decimal :PayAmountRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -153,12 +153,12 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:payAmount ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ] + [ sh:path odrl:rightOperand ; sh:node :DecimalShape ] ) ; - sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative." . + sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal." . -# R74: the rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer between 0 and 100 +# R74: the rightOperand of odrl:percentage must be an xsd:decimal between 0 and 100 :PercentageRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -166,9 +166,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:percentage ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ; sh:maxInclusive 100 ] + [ sh:path odrl:rightOperand ; sh:node :DecimalShape ; sh:minInclusive 0 ; sh:maxInclusive 100 ] ) ; - sh:message "The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100." . + sh:message "The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100." . # R76: the rightOperand of odrl:product must be an IRI or a string @@ -179,7 +179,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:product ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:product should be an IRI, a string, or a list of these." . @@ -192,7 +192,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:purpose ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:purpose should be an IRI, a string, or a list of these." . @@ -205,7 +205,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:recipient ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:recipient should be an IRI, a string, or a list of these." . @@ -231,7 +231,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:systemDevice ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:systemDevice should be an IRI, a string, or a list of these." . @@ -244,7 +244,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:timeInterval ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:timeInterval must be an xsd:duration." . @@ -257,7 +257,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:unitOfCount ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:string ] + [ sh:path odrl:rightOperand ; sh:node :StringShape ] ) ; sh:message "The rightOperand of odrl:unitOfCount should be a string." . @@ -270,7 +270,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:version ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:version should be a string or a list of strings." . @@ -283,7 +283,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:virtualLocation ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:virtualLocation should be a string or a list of strings." . @@ -294,7 +294,7 @@ sh:node :RdfListShape ; sh:property [ sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ; - sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] ) ; + sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] ) ; ] . # An RDF list whose members are strings @@ -302,5 +302,63 @@ sh:node :RdfListShape ; sh:property [ sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ; - sh:datatype xsd:string ; - ] . \ No newline at end of file + sh:node :StringShape ; + ] . + +# Subtypes: https://www.w3.org/TR/xmlschema11-2/#built-in-datatypes + +# xsd:decimal and subtypes +:DecimalShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:decimal ] + [ sh:node :IntegerShape ] + ) . + +# xsd:integer and subtypes +:IntegerShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:integer ] + [ sh:datatype xsd:long ] + [ sh:datatype xsd:int ] + [ sh:datatype xsd:short ] + [ sh:datatype xsd:byte ] + [ sh:datatype xsd:nonNegativeInteger ] + [ sh:datatype xsd:positiveInteger ] + [ sh:datatype xsd:unsignedLong ] + [ sh:datatype xsd:unsignedInt ] + [ sh:datatype xsd:unsignedShort ] + [ sh:datatype xsd:unsignedByte ] + [ sh:datatype xsd:nonPositiveInteger ] + [ sh:datatype xsd:negativeInteger ] + ) . + +# xsd:date, xsd:dateTime and subtypes +:DateTimeShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:date ] + [ sh:datatype xsd:dateTime ] + [ sh:datatype xsd:dateTimeStamp ] + ) . + +# xsd:duration and subtypes +:DurationShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:duration ] + [ sh:datatype xsd:dayTimeDuration ] + [ sh:datatype xsd:yearMonthDuration ] + ) . + +# xsd:string and subtypes +:StringShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:string ] + [ sh:datatype xsd:normalizedString ] + [ sh:datatype xsd:token ] + [ sh:datatype xsd:language ] + [ sh:datatype xsd:Name ] + [ sh:datatype xsd:NCName ] + [ sh:datatype xsd:ENTITY ] + [ sh:datatype xsd:ID ] + [ sh:datatype xsd:IDREF ] + [ sh:datatype xsd:NMTOKEN ] + ) . diff --git a/src/shapes/odrl-shapes.ttl b/src/shapes/odrl-shapes.ttl index f2eb48a..9798d94 100644 --- a/src/shapes/odrl-shapes.ttl +++ b/src/shapes/odrl-shapes.ttl @@ -1299,7 +1299,7 @@ # RightOperand datatype per leftOperand ################################################# -# R50: the rightOperand of odrl:count must be an xsd:integer +# R50: the rightOperand of odrl:count must be an xsd:integer, not negative :CountRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -1307,9 +1307,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:count ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:integer ] + [ sh:path odrl:rightOperand ; sh:node :IntegerShape ; sh:minInclusive 0 ] ) ; - sh:message "The rightOperand of odrl:count must be an xsd:integer." . + sh:message "The rightOperand of odrl:count must be an xsd:integer, not negative." . # R52: the rightOperand of odrl:dateTime must be an xsd:date or xsd:dateTime @@ -1320,7 +1320,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:dateTime ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:date ] [ sh:datatype xsd:dateTime ] ) ] + [ sh:path odrl:rightOperand ; sh:node :DateTimeShape ] ) ; sh:message "The rightOperand of odrl:dateTime must be an xsd:date or xsd:dateTime." . @@ -1333,7 +1333,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:delayPeriod ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:delayPeriod must be an xsd:duration." . @@ -1346,7 +1346,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:deliveryChannel ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:deliveryChannel should be an IRI, a string, or a list of these." . @@ -1359,7 +1359,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:elapsedTime ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:elapsedTime must be an xsd:duration." . @@ -1372,7 +1372,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:event ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] ) ] ) ; sh:message "The rightOperand of odrl:event should be an IRI or a string." . @@ -1385,7 +1385,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:fileFormat ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:fileFormat should be an IRI, a string, or a list of these." . @@ -1398,7 +1398,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:industry ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:industry should be an IRI, a string, or a list of these." . @@ -1411,7 +1411,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:language ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:language should be a string or a list of strings." . @@ -1424,7 +1424,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:media ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:media should be a string or a list of strings." . @@ -1437,12 +1437,12 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:meteredTime ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:meteredTime must be an xsd:duration." . -# R72: the rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative +# R72: the rightOperand of odrl:payAmount must be an xsd:decimal :PayAmountRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -1450,12 +1450,12 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:payAmount ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ] + [ sh:path odrl:rightOperand ; sh:node :DecimalShape ] ) ; - sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative." . + sh:message "The rightOperand of odrl:payAmount must be an xsd:decimal." . -# R74: the rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer between 0 and 100 +# R74: the rightOperand of odrl:percentage must be an xsd:decimal between 0 and 100 :PercentageRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -1463,9 +1463,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:percentage ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:decimal ] [ sh:datatype xsd:integer ] ) ; sh:minInclusive 0 ; sh:maxInclusive 100 ] + [ sh:path odrl:rightOperand ; sh:node :DecimalShape ; sh:minInclusive 0 ; sh:maxInclusive 100 ] ) ; - sh:message "The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100." . + sh:message "The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100." . # R76: the rightOperand of odrl:product must be an IRI or a string @@ -1476,7 +1476,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:product ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:product should be an IRI, a string, or a list of these." . @@ -1489,7 +1489,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:purpose ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:purpose should be an IRI, a string, or a list of these." . @@ -1502,7 +1502,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:recipient ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:recipient should be an IRI, a string, or a list of these." . @@ -1528,7 +1528,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:systemDevice ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] [ sh:node :IriOrStringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] [ sh:node :IriOrStringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:systemDevice should be an IRI, a string, or a list of these." . @@ -1541,7 +1541,7 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:timeInterval ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:duration ] + [ sh:path odrl:rightOperand ; sh:node :DurationShape ] ) ; sh:message "The rightOperand of odrl:timeInterval must be an xsd:duration." . @@ -1554,7 +1554,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:unitOfCount ] ] - [ sh:path odrl:rightOperand ; sh:datatype xsd:string ] + [ sh:path odrl:rightOperand ; sh:node :StringShape ] ) ; sh:message "The rightOperand of odrl:unitOfCount should be a string." . @@ -1567,7 +1567,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:version ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:version should be a string or a list of strings." . @@ -1580,7 +1580,7 @@ sh:severity sh:Warning ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:virtualLocation ] ] - [ sh:path odrl:rightOperand ; sh:or ( [ sh:datatype xsd:string ] [ sh:node :StringListShape ] ) ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:node :StringShape ] [ sh:node :StringListShape ] ) ] ) ; sh:message "The rightOperand of odrl:virtualLocation should be a string or a list of strings." . @@ -1591,7 +1591,7 @@ sh:node :RdfListShape ; sh:property [ sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ; - sh:or ( [ sh:nodeKind sh:IRI ] [ sh:datatype xsd:string ] ) ; + sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] ) ; ] . # An RDF list whose members are strings @@ -1599,5 +1599,63 @@ sh:node :RdfListShape ; sh:property [ sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ; - sh:datatype xsd:string ; + sh:node :StringShape ; ] . + +# Subtypes: https://www.w3.org/TR/xmlschema11-2/#built-in-datatypes + +# xsd:decimal and subtypes +:DecimalShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:decimal ] + [ sh:node :IntegerShape ] + ) . + +# xsd:integer and subtypes +:IntegerShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:integer ] + [ sh:datatype xsd:long ] + [ sh:datatype xsd:int ] + [ sh:datatype xsd:short ] + [ sh:datatype xsd:byte ] + [ sh:datatype xsd:nonNegativeInteger ] + [ sh:datatype xsd:positiveInteger ] + [ sh:datatype xsd:unsignedLong ] + [ sh:datatype xsd:unsignedInt ] + [ sh:datatype xsd:unsignedShort ] + [ sh:datatype xsd:unsignedByte ] + [ sh:datatype xsd:nonPositiveInteger ] + [ sh:datatype xsd:negativeInteger ] + ) . + +# xsd:date, xsd:dateTime and subtypes +:DateTimeShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:date ] + [ sh:datatype xsd:dateTime ] + [ sh:datatype xsd:dateTimeStamp ] + ) . + +# xsd:duration and subtypes +:DurationShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:duration ] + [ sh:datatype xsd:dayTimeDuration ] + [ sh:datatype xsd:yearMonthDuration ] + ) . + +# xsd:string and subtypes +:StringShape a sh:NodeShape ; + sh:or ( + [ sh:datatype xsd:string ] + [ sh:datatype xsd:normalizedString ] + [ sh:datatype xsd:token ] + [ sh:datatype xsd:language ] + [ sh:datatype xsd:Name ] + [ sh:datatype xsd:NCName ] + [ sh:datatype xsd:ENTITY ] + [ sh:datatype xsd:ID ] + [ sh:datatype xsd:IDREF ] + [ sh:datatype xsd:NMTOKEN ] + ) . diff --git a/test/unit/ConstraintShapes.test.ts b/test/unit/ConstraintShapes.test.ts index 04eb1e3..dff962c 100644 --- a/test/unit/ConstraintShapes.test.ts +++ b/test/unit/ConstraintShapes.test.ts @@ -8,7 +8,7 @@ const MESSAGES = { R47: 'odrl:absoluteTemporalPosition is only compatible with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', R48: 'odrl:absoluteSize is only compatible with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', R49: 'odrl:count is only compatible with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', - R50: 'The rightOperand of odrl:count must be an xsd:integer.', + R50: 'The rightOperand of odrl:count must be an xsd:integer, not negative.', R51: 'odrl:dateTime must only be used with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', R52: 'The rightOperand of odrl:dateTime must be an xsd:date or xsd:dateTime.', R53: 'odrl:delayPeriod must only be used with odrl:eq, odrl:gt or odrl:gteq.', @@ -30,9 +30,9 @@ const MESSAGES = { R69: 'odrl:meteredTime must only be used with odrl:eq, odrl:lt or odrl:lteq.', R70: 'The rightOperand of odrl:meteredTime must be an xsd:duration.', R71: 'odrl:payAmount must only be used with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', - R72: 'The rightOperand of odrl:payAmount must be an xsd:decimal or xsd:integer, not negative.', + R72: 'The rightOperand of odrl:payAmount must be an xsd:decimal.', R73: 'odrl:percentage must only be used with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', - R74: 'The rightOperand of odrl:percentage must be an xsd:decimal or xsd:integer from 0 to 100.', + R74: 'The rightOperand of odrl:percentage must be an xsd:decimal from 0 to 100.', R75: 'odrl:product must only be used with odrl:eq, odrl:neq, odrl:isA, odrl:isAnyOf or odrl:isNoneOf.', R76: 'The rightOperand of odrl:product should be an IRI, a string, or a list of these.', R77: 'odrl:purpose must only be used with odrl:eq, odrl:neq, odrl:isA, odrl:isAnyOf or odrl:isNoneOf.', @@ -147,9 +147,14 @@ describe('The constraint rightOperand shapes', () => { // [requirement, leftOperand, rightOperand] test.each([ [ 'R50', 'odrl:count', '"5"^^xsd:integer' ], + [ 'R50', 'odrl:count', '"5"^^xsd:nonNegativeInteger' ], + [ 'R50', 'odrl:count', '"1"^^xsd:positiveInteger' ], + [ 'R50', 'odrl:count', '"0"^^xsd:integer' ], [ 'R52', 'odrl:dateTime', '"2026-12-31"^^xsd:date' ], [ 'R52', 'odrl:dateTime', '"2026-12-31T10:00:00Z"^^xsd:dateTime' ], + [ 'R52', 'odrl:dateTime', '"2026-12-31T10:00:00Z"^^xsd:dateTimeStamp' ], [ 'R54', 'odrl:delayPeriod', '"PT60M"^^xsd:duration' ], + [ 'R54', 'odrl:delayPeriod', '"PT60M"^^xsd:dayTimeDuration' ], [ 'R56', 'odrl:deliveryChannel', ':mobile' ], [ 'R56', 'odrl:deliveryChannel', '"mobile"' ], [ 'R56', 'odrl:deliveryChannel', '( :mobile "web" )' ], @@ -164,6 +169,7 @@ describe('The constraint rightOperand shapes', () => { [ 'R64', 'odrl:industry', '"financial"' ], [ 'R64', 'odrl:industry', '( :publishing "financial" )' ], [ 'R66', 'odrl:language', '"en"' ], + [ 'R66', 'odrl:language', '"en"^^xsd:language' ], [ 'R66', 'odrl:language', '( "en" "es" )' ], [ 'R68', 'odrl:media', '"print"' ], [ 'R68', 'odrl:media', '( "electronic" "print" )' ], @@ -172,11 +178,14 @@ describe('The constraint rightOperand shapes', () => { [ 'R72', 'odrl:payAmount', '10.5' ], [ 'R72', 'odrl:payAmount', '10' ], [ 'R72', 'odrl:payAmount', '0' ], + [ 'R72', 'odrl:payAmount', '"10"^^xsd:nonNegativeInteger' ], + [ 'R72', 'odrl:payAmount', '-10' ], [ 'R74', 'odrl:percentage', '"50"^^xsd:decimal' ], [ 'R74', 'odrl:percentage', '"0.0"^^xsd:decimal' ], [ 'R74', 'odrl:percentage', '"100.0"^^xsd:decimal' ], [ 'R74', 'odrl:percentage', '50' ], [ 'R74', 'odrl:percentage', '100' ], + [ 'R74', 'odrl:percentage', '"50"^^xsd:unsignedByte' ], [ 'R76', 'odrl:product', ':magazine' ], [ 'R76', 'odrl:product', '"magazine"' ], [ 'R76', 'odrl:product', '( :magazine "newspaper" )' ], @@ -191,6 +200,7 @@ describe('The constraint rightOperand shapes', () => { [ 'R90', 'odrl:systemDevice', '"device-1234"' ], [ 'R90', 'odrl:systemDevice', '( :laptop42 "device-1234" )' ], [ 'R92', 'odrl:timeInterval', '"P7D"^^xsd:duration' ], + [ 'R92', 'odrl:timeInterval', '"P1M"^^xsd:yearMonthDuration' ], [ 'R94', 'odrl:unitOfCount', '"perUser"' ], [ 'R96', 'odrl:version', '"2.0"' ], [ 'R96', 'odrl:version', '( "1.0" "2.0" )' ], @@ -204,6 +214,7 @@ describe('The constraint rightOperand shapes', () => { const wrongCases: [keyof typeof MESSAGES, string, string, Severity][] = [ [ 'R50', 'odrl:count', '"five"', 'Violation' ], [ 'R50', 'odrl:count', '"5.5"^^xsd:decimal', 'Violation' ], + [ 'R50', 'odrl:count', '"-5"^^xsd:negativeInteger', 'Violation' ], [ 'R52', 'odrl:dateTime', '"tomorrow"', 'Violation' ], [ 'R52', 'odrl:dateTime', '"5"^^xsd:integer', 'Violation' ], [ 'R52', 'odrl:dateTime', '"2026-13-45"^^xsd:date', 'Violation' ], @@ -228,8 +239,6 @@ describe('The constraint rightOperand shapes', () => { [ 'R72', 'odrl:payAmount', '"10 EUR"', 'Violation' ], [ 'R72', 'odrl:payAmount', '"abc"^^xsd:decimal', 'Violation' ], [ 'R72', 'odrl:payAmount', '"10.5"^^xsd:double', 'Violation' ], - [ 'R72', 'odrl:payAmount', '-10', 'Violation' ], - [ 'R72', 'odrl:payAmount', '"-0.5"^^xsd:decimal', 'Violation' ], [ 'R74', 'odrl:percentage', '"100.5"^^xsd:decimal', 'Violation' ], [ 'R74', 'odrl:percentage', '"-1"^^xsd:decimal', 'Violation' ], [ 'R74', 'odrl:percentage', '"50%"', 'Violation' ], From 9920834a63435c05822efa55cc610a8e177d0e1a Mon Sep 17 00:00:00 2001 From: marmolpen3 Date: Tue, 17 Nov 2026 21:30:27 +0100 Subject: [PATCH 3/3] fix: accept a list of IRIs as rightOperand of odrl:spatial --- docs/Requirements.md | 2 +- src/shapes/Shapes.ts | 19 ++++++++++++++++--- .../08-odrl-constraint-right-operands.ttl | 14 +++++++++++--- src/shapes/odrl-shapes.ttl | 14 +++++++++++--- test/unit/ConstraintShapes.test.ts | 6 +++--- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/docs/Requirements.md b/docs/Requirements.md index 3a5d529..69b6b57 100644 --- a/docs/Requirements.md +++ b/docs/Requirements.md @@ -100,7 +100,7 @@ Each XSD datatype also includes its subtypes (e.g. xsd:integer is an xsd:decimal - R84: odrl:relativeSize is only compatible with comparison operators - Violation - **New** - R85: odrl:resolution is only compatible with comparison operators - Violation - **New** - R86: odrl:spatial is only compatible with eq, neq, isAnyOf, isNoneOf - Violation - **New** -- R87: The rightOperand for odrl:spatial must be an IRI - Violation - **New** +- R87: The rightOperand for odrl:spatial must be an IRI or a list of IRIs - Violation - **New** - R88: odrl:spatialCoordinates is only compatible with eq, neq - Violation - **New** - R89: odrl:systemDevice is only compatible with eq, neq, isAnyOf, isNoneOf - Violation - **New** - R90: The rightOperand for odrl:systemDevice must be an IRI or a string - Warning - **New** diff --git a/src/shapes/Shapes.ts b/src/shapes/Shapes.ts index ff18bdb..e1d8b32 100644 --- a/src/shapes/Shapes.ts +++ b/src/shapes/Shapes.ts @@ -1493,7 +1493,7 @@ export const SHAPES: string = `@prefix odrl: . a sh:NodeShape ; sh:targetClass odrl:Constraint ; sh:targetSubjectsOf odrl:leftOperand ; - sh:message "The rightOperand of odrl:spatial must be an IRI." ; + sh:message "The rightOperand of odrl:spatial must be an IRI or a list of IRIs." ; sh:severity sh:Violation ; sh:or ([ sh:not [ @@ -1501,10 +1501,23 @@ export const SHAPES: string = `@prefix odrl: . sh:hasValue odrl:spatial ] ] [ - sh:nodeKind sh:IRI ; - sh:path odrl:rightOperand + sh:path odrl:rightOperand ; + sh:or ([ + sh:nodeKind sh:IRI + ] [ + sh:node + ]) ]) . + a sh:NodeShape ; + sh:property [ + sh:nodeKind sh:IRI ; + sh:path ([ + sh:zeroOrMorePath rdf:rest + ] rdf:first) + ] ; + sh:node . + a sh:NodeShape ; sh:targetClass odrl:Constraint ; sh:targetSubjectsOf odrl:leftOperand ; diff --git a/src/shapes/modules/08-odrl-constraint-right-operands.ttl b/src/shapes/modules/08-odrl-constraint-right-operands.ttl index 0237786..2c9211a 100644 --- a/src/shapes/modules/08-odrl-constraint-right-operands.ttl +++ b/src/shapes/modules/08-odrl-constraint-right-operands.ttl @@ -210,7 +210,7 @@ sh:message "The rightOperand of odrl:recipient should be an IRI, a string, or a list of these." . -# R87: the rightOperand of odrl:spatial must be an IRI +# R87: the rightOperand of odrl:spatial must be an IRI or a list of IRIs :SpatialRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -218,9 +218,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:spatial ] ] - [ sh:path odrl:rightOperand ; sh:nodeKind sh:IRI ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :IriListShape ] ) ] ) ; - sh:message "The rightOperand of odrl:spatial must be an IRI." . + sh:message "The rightOperand of odrl:spatial must be an IRI or a list of IRIs." . # R90: the rightOperand of odrl:systemDevice must be an IRI or a string @@ -297,6 +297,14 @@ sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] ) ; ] . +# An RDF list whose members are IRIs +:IriListShape a sh:NodeShape ; + sh:node :RdfListShape ; + sh:property [ + sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ; + sh:nodeKind sh:IRI ; + ] . + # An RDF list whose members are strings :StringListShape a sh:NodeShape ; sh:node :RdfListShape ; diff --git a/src/shapes/odrl-shapes.ttl b/src/shapes/odrl-shapes.ttl index 9798d94..129c0fb 100644 --- a/src/shapes/odrl-shapes.ttl +++ b/src/shapes/odrl-shapes.ttl @@ -1507,7 +1507,7 @@ sh:message "The rightOperand of odrl:recipient should be an IRI, a string, or a list of these." . -# R87: the rightOperand of odrl:spatial must be an IRI +# R87: the rightOperand of odrl:spatial must be an IRI or a list of IRIs :SpatialRightOperandShape a sh:NodeShape ; sh:targetClass odrl:Constraint ; @@ -1515,9 +1515,9 @@ sh:severity sh:Violation ; sh:or ( [ sh:not [ sh:path odrl:leftOperand ; sh:hasValue odrl:spatial ] ] - [ sh:path odrl:rightOperand ; sh:nodeKind sh:IRI ] + [ sh:path odrl:rightOperand ; sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :IriListShape ] ) ] ) ; - sh:message "The rightOperand of odrl:spatial must be an IRI." . + sh:message "The rightOperand of odrl:spatial must be an IRI or a list of IRIs." . # R90: the rightOperand of odrl:systemDevice must be an IRI or a string @@ -1594,6 +1594,14 @@ sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node :StringShape ] ) ; ] . +# An RDF list whose members are IRIs +:IriListShape a sh:NodeShape ; + sh:node :RdfListShape ; + sh:property [ + sh:path ( [ sh:zeroOrMorePath rdf:rest ] rdf:first ) ; + sh:nodeKind sh:IRI ; + ] . + # An RDF list whose members are strings :StringListShape a sh:NodeShape ; sh:node :RdfListShape ; diff --git a/test/unit/ConstraintShapes.test.ts b/test/unit/ConstraintShapes.test.ts index dff962c..aa9a3d7 100644 --- a/test/unit/ConstraintShapes.test.ts +++ b/test/unit/ConstraintShapes.test.ts @@ -45,7 +45,7 @@ const MESSAGES = { R84: 'odrl:relativeSize must only be used with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', R85: 'odrl:resolution must only be used with comparison operators odrl:eq, odrl:gt, odrl:gteq, odrl:lt, odrl:lteq or odrl:neq.', R86: 'odrl:spatial must only be used with odrl:eq, odrl:neq, odrl:isAnyOf or odrl:isNoneOf.', - R87: 'The rightOperand of odrl:spatial must be an IRI.', + R87: 'The rightOperand of odrl:spatial must be an IRI or a list of IRIs.', R88: 'odrl:spatialCoordinates must only be used with odrl:eq or odrl:neq.', R89: 'odrl:systemDevice must only be used with odrl:eq, odrl:neq, odrl:isAnyOf or odrl:isNoneOf.', R90: 'The rightOperand of odrl:systemDevice should be an IRI, a string, or a list of these.', @@ -196,6 +196,7 @@ describe('The constraint rightOperand shapes', () => { [ 'R80', 'odrl:recipient', '"Bob"' ], [ 'R80', 'odrl:recipient', '( :alice "Bob" )' ], [ 'R87', 'odrl:spatial', '' ], + [ 'R87', 'odrl:spatial', '( )' ], [ 'R90', 'odrl:systemDevice', ':laptop42' ], [ 'R90', 'odrl:systemDevice', '"device-1234"' ], [ 'R90', 'odrl:systemDevice', '( :laptop42 "device-1234" )' ], @@ -252,8 +253,7 @@ describe('The constraint rightOperand shapes', () => { [ 'R80', 'odrl:recipient', '"5"^^xsd:integer', 'Warning' ], [ 'R80', 'odrl:recipient', '( :alice "5"^^xsd:integer )', 'Warning' ], [ 'R87', 'odrl:spatial', '"ES"', 'Violation' ], - // Lists are blank nodes, so they are not allowed either (to be discussed for isAnyOf/isNoneOf). - [ 'R87', 'odrl:spatial', '( )', 'Violation' ], + [ 'R87', 'odrl:spatial', '( "France" )', 'Violation' ], [ 'R90', 'odrl:systemDevice', '"5"^^xsd:integer', 'Warning' ], [ 'R90', 'odrl:systemDevice', '( :laptop42 "5"^^xsd:integer )', 'Warning' ], [ 'R92', 'odrl:timeInterval', '"weekly"', 'Violation' ],