Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PositiveIntegerRange must have beginIntegerRange <= endIntegerRange #926

Open
ilans opened this issue Nov 20, 2024 · 0 comments
Open

PositiveIntegerRange must have beginIntegerRange <= endIntegerRange #926

ilans opened this issue Nov 20, 2024 · 0 comments
Labels
Profile:Core Core Profile and related matters Profile:Software Software Profile and related matters RDF/OWL/SHACL RDF graph, schema, ontology, constraint
Milestone

Comments

@ilans
Copy link
Collaborator

ilans commented Nov 20, 2024

From PositiveIntegerRange:

"beginIntegerRange" must be less than or equal to "endIntegerRange"

Suggested SHACL shapes:

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix spdxcore: <https://spdx.org/rdf/3.0.1/terms/Core/> .

spdxcore:PositiveIntegerRange
    sh:property [
        sh:path spdxcore:beginIntegerRange ;
        sh:datatype xsd:positiveInteger ;
        sh:lessThanOrEquals spdxcore:endIntegerRange ;
        sh:message "beginIntegerRange must be less than or equal to endIntegerRange" ;
    ] .

Test data:

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix spdxcore: <https://spdx.org/rdf/3.0.1/terms/Core/> .
@prefix spdxsw: <https://spdx.org/rdf/3.0.1/terms/Software/> .
@prefix ex: <http://example.org/ns#> .

ex:MyAgent
    a spdxcore:Agent ;
    spdxcore:creationInfo _:MyCreationInfo .

_:MyCreationInfo
    a spdxcore:CreationInfo ;
    spdxcore:createdBy ex:MyAgent ;
    spdxcore:created "2024-09-04T20:25:34Z"^^xsd:dateTimeStamp ;
    spdxcore:specVersion "3.0.1" .

ex:MyFile
    a spdxsw:File ;
    spdxcore:creationInfo _:MyCreationInfo .

ex:ValidLessThan
    a spdxsw:Snippet ;
    spdxcore:creationInfo _:MyCreationInfo ;
    spdxsw:snippetFromFile ex:MyFile ;
    spdxsw:byteRange [
        a spdxcore:PositiveIntegerRange ;
        spdxcore:beginIntegerRange "1"^^xsd:positiveInteger ;
        spdxcore:endIntegerRange "2"^^xsd:positiveInteger
    ] .

ex:ValidEqual
    a spdxsw:Snippet ;
    spdxcore:creationInfo _:MyCreationInfo ;
    spdxsw:snippetFromFile ex:MyFile ;
    spdxsw:byteRange [
        a spdxcore:PositiveIntegerRange ;
        spdxcore:beginIntegerRange "2"^^xsd:positiveInteger ;
        spdxcore:endIntegerRange "2"^^xsd:positiveInteger
    ] .

ex:InvalidMoreThan
    a spdxsw:Snippet ;
    spdxcore:creationInfo _:MyCreationInfo ;
    spdxsw:snippetFromFile ex:MyFile ;
    spdxsw:byteRange [
        a spdxcore:PositiveIntegerRange ;
        spdxcore:beginIntegerRange "3"^^xsd:positiveInteger ;
        spdxcore:endIntegerRange "2"^^xsd:positiveInteger
    ] .

Test script:
https://raw.githubusercontent.com/condots/dots/refs/heads/main/scripts/test-shacl.py

Test results:

----------------------------------------------------------------------------------------------------
Violation message: beginIntegerRange must be less than or equal to endIntegerRange
Violation constraint: LessThanOrEqualsConstraintComponent
Violation value: 3
Property path: https://spdx.org/rdf/3.0.1/terms/Core/beginIntegerRange
Focus node: n3c1eb59301f3477caa3aadba7897d57cb4
BlankNode parent: http://example.org/ns#InvalidMoreThan
----------------------------------------------------------------------------------------------------
@ilans ilans added Profile:Core Core Profile and related matters Profile:Software Software Profile and related matters RDF/OWL/SHACL RDF graph, schema, ontology, constraint labels Nov 20, 2024
@bact bact added this to the 3.1 milestone Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Profile:Core Core Profile and related matters Profile:Software Software Profile and related matters RDF/OWL/SHACL RDF graph, schema, ontology, constraint
Projects
None yet
Development

No branches or pull requests

2 participants