Interoperable-data / ERA_vocabulary

ERA vocabulary is an ontology defined by the European Union Agency for Railways (ERA) to describe the concepts and relationships related to the European railway infrastructure and the vehicles authorized to operate over it.
https://data-interop.era.europa.eu/era-vocabulary/
MIT License
4 stars 3 forks source link

Shape for "length in meters" is doubtful #21

Open VladimirAlexiev opened 1 month ago

VladimirAlexiev commented 1 month ago
era-sh:length
    a sh:PropertyShape;
    sh:datatype xsd:double ;
    sh:pattern "([1-9]\\d{3}|[1-9]\\d{2}|[1-9]\\d{1}|[0-9])" ;
    sh:message "length (1.2.2.0.2.1): Each Siding must have a length in meters."@en

If you want to limit to 0..999 then use sh:minInclusive. maxExclusive. Don't use sh:pattern

ednaru commented 1 month ago

Thanks, We have created a ticket in order to fix this bug.

StephaneBranly commented 1 month ago
  • this doesn't allow 0 to appear in multi-digit numbers, eg 109 and 100 are not allowed

...

If you want to limit to 0..999 then use sh:minInclusive. maxExclusive. Don't use sh:pattern

I am not sure to understand why this pattern rejects 109 and 100. It can be simplified as ([1-9]\d{3}|[1-9]\d{2}|[1-9]\d{1}|[0-9]) -> ([1-9]\d{1,3}|\d) -> \d which is valid if the string contains at least one digit. Is the wanted regex ^([1-9]\d{1,3}|\d)$ whichs allows every integer between 0 and 9999 ?

Looks like the type should be xsd:integer with sh:minExclusive 0

VladimirAlexiev commented 1 month ago

@StephaneBranly You're right, 0 is allowed in the middle. But surely the length of a siding can be a fractional number: so I think it should stay as xsd:double.

There's no need to worry about leading zeros because according to RDF semantics they don't matter. Eg try at https://sparql.org/sparql.html, the two literals are equal:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select ("012"^^xsd:double="12"^^xsd:double) {}

If you need to prevent leading zeros, the best is to use an explicit pattern like this

sh:pattern "^[^0]"