Skip to content

Check for hasPart path from root data entity to data entities #148

@floWetzels

Description

@floWetzels

The RO-Crate specification requires every data entity to be directly or indirectly linked from the root data entity via the attribute hasPart. However, the current validator only checks for a direkt link from another Dataset object. Here the respective SHACL code:

sh:path [ sh:inversePath schema_org:hasPart ] ;
sh:node schema_org:Dataset ;
sh:minCount 1 ;

After discussing this with @elichad, we concluded that this is a bug and should be fixed. If there are isolated Dataset objects with cyclic references, the validator deems this a valid RO-Crate. A simple example crate that triggers this behavior is attached at the bottom.
A fix for this issue using sh:oneOrMorePath, sh:qualifiedValueShape and sh:qualifiedMinCount, as well as corresponding test cases, are implemented on this branch: https://github.com/nfdi4plants/rocrate-validator/tree/fix-cyclic-datasets.
If we didn't overlook something that makes the current behavior correct or intended, I could open a PR.

Example crate:

{
    "@context": [
        "https://w3id.org/ro/crate/1.1/context"
    ],
    "@graph": [
        {
            "@id": "ro-crate-metadata.json",
            "@type": "CreativeWork",
            "conformsTo": {
                "@id": "https://w3id.org/ro/crate/1.1"
            },
            "about": {
                "@id": "./"
            }
        },
        {
            "@id": "./",
            "@type": "Dataset",
            "name": "Root",
            "description": "Root Dataset",
            "datePublished": "2024-05-17T01:04:52+01:00",
            "hasPart": [
            ],
            "license": "CC-BY-4.0"
        },
        {
            "@id": "dataset1/file1.txt",
            "@type": "File",
            "description": "A file",
            "encodingFormat": "text/plain",
            "name": "file1.txt"
        },
        {
            "@id": "dataset2/file2.txt",
            "@type": "File",
            "description": "Another file",
            "encodingFormat": "text/plain",
            "name": "file2.txt"
        },
        {
            "@id": "dataset1/",
            "@type": "Dataset",
            "name": "Dataset 1",
            "description": "First dataset",
            "hasPart": [
                {
                    "@id": "dataset1/file1.txt"
                },
                {
                    "@id": "dataset2/"
                }
            ]
        },
        {
            "@id": "dataset2/",
            "@type": "Dataset",
            "name": "Dataset 2",
            "description": "Second dataset",
            "hasPart": [
                {
                    "@id": "dataset2/file2.txt"
                },
                {
                    "@id": "dataset1/"
                }
            ]
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions