Shacl

Warning

Beta implementation, some features may change

Example Output

personinfo.shacl.ttl

Overview

SHACL (Shapes Constraint Language) is a language for validating RDF graphs against a set of conditions

To run:

gen-shacl personinfo.yaml > personinfo.shacl.ttl

Docs

Example Input:

NamedThing:
  slots:
    - id
    - name

HasAliases:
  mixin: true
  attributes:
    aliases:
      multivalued: true

Person:
  is_a: NamedThing
  mixins:
    - HasAliases
  slots:
    - birth_date
    - age_in_years
    - gender

Example Output:

<https://w3id.org/linkml/tests/kitchen_sink/Person> a shacl:NodeShape ;
    shacl:closed true ;
    shacl:ignoredProperties ( rdf:type ) ;
    shacl:property [ shacl:class <https://w3id.org/linkml/tests/kitchen_sink/BirthEvent> ;
            shacl:maxCount 1 ;
            shacl:nodeKind shacl:BlankNode ;
            shacl:path <https://w3id.org/linkml/tests/kitchen_sink/has_birth_event> ],
        [ shacl:maxCount 1 ;
            shacl:maxInclusive 999 ;
            shacl:minInclusive 0 ;
            shacl:path <https://w3id.org/linkml/tests/kitchen_sink/age_in_years> ],
        [ shacl:class <https://w3id.org/linkml/tests/kitchen_sink/FamilialRelationship> ;
            shacl:nodeKind shacl:BlankNode ;
            shacl:path <https://w3id.org/linkml/tests/kitchen_sink/has_familial_relationships> ],
        [ shacl:maxCount 1 ;
            shacl:path <https://w3id.org/linkml/tests/core/name> ;
            shacl:pattern "^\\S+ \\S+" ],
        [ shacl:class <https://w3id.org/linkml/tests/kitchen_sink/MedicalEvent> ;
            shacl:nodeKind shacl:BlankNode ;
            shacl:path <https://w3id.org/linkml/tests/kitchen_sink/has_medical_history> ],
        [ shacl:class <https://w3id.org/linkml/tests/kitchen_sink/Address> ;
            shacl:nodeKind shacl:BlankNode ;
            shacl:path <https://w3id.org/linkml/tests/kitchen_sink/addresses> ],
        [ shacl:maxCount 1 ;
            shacl:path <https://w3id.org/linkml/tests/core/id> ],
        [ shacl:path <https://w3id.org/linkml/tests/kitchen_sink/aliases> ],
        [ shacl:class <https://w3id.org/linkml/tests/kitchen_sink/EmploymentEvent> ;
            shacl:nodeKind shacl:BlankNode ;
            shacl:path <https://w3id.org/linkml/tests/kitchen_sink/has_employment_history> ] ;
    shacl:targetClass <https://w3id.org/linkml/tests/kitchen_sink/Person> .

Command Line

Code