ShEx#

Example Output#

personinfo.shex

Overview#

ShEx, short for Shape Expressions Language is a modeling language for RDF files. This generator can be used to create ShEx shapefiles, which can then be used to validate RDF data.

ShEx provides similar functionality to SHACL, which has its own validator

To run:

gen-shex personinfo.yaml > personinfo.shex

Translation#

An example of translating the personinfo schema is shown below.

<NamedThing>  (
    CLOSED {
       (  $<NamedThing_tes> (  schema:name @linkml:String ? ;
             schema:description @linkml:String ? ;
             schema:image @linkml:String ?
          ) ;
          rdf:type [ <NamedThing> ]
       )
    } OR @<Concept> OR @<Organization> OR @<Person>
)
<Person> CLOSED {
    (  $<Person_tes> (  &<NamedThing_tes> ;
          rdf:type [ <NamedThing> ] ? ;
          &<HasAliases_tes> ;
          rdf:type [ <HasAliases> ] ? ;
          <primary_email> @linkml:String ? ;
          schema:birthDate @linkml:String ? ;
          <age_in_years> @linkml:Integer ? ;
          schema:gender @<GenderType> ? ;
          <current_address> @<Address> ? ;
          <has_employment_history> @<EmploymentEvent> * ;
          <has_familial_relationships> @<FamilialRelationship> * ;
          <has_medical_history> @<MedicalEvent> * ;
          <aliases> @linkml:String *
       ) ;
       rdf:type [ schema:Person ]
    )
}

Docs#

Command Line#

gen-shex#

Generate a ShEx Schema for a LinkML model

gen-shex [OPTIONS] YAMLFILE

Options

-o, --output <output>#

Output file name

-V, --version#

Show the version and exit.

-f, --format <format>#

Output format

Default:

shex

Options:

shex | json | rdf

--metadata, --no-metadata#

Include metadata in output

Default:

True

--useuris, --metauris#

Use class and slot URIs over model uris

Default:

True

-im, --importmap <importmap>#

Import mapping file

--log_level <log_level>#

Logging level

Default:

WARNING

Options:

CRITICAL | ERROR | WARNING | INFO | DEBUG

-v, --verbose#

Verbosity. Takes precedence over –log_level.

--mergeimports, --no-mergeimports#

Merge imports into source file (default=mergeimports)

--stacktrace, --no-stacktrace#

Print a stack trace when an error occurs

Default:

False

Arguments

YAMLFILE#

Required argument

Code#