ShEx
Example Output
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
- -f, --format <format>
Output format (default=shex)
- Options
shex | json | rdf
- --metadata, --no-metadata
Include metadata in output (default=–metadata)
- --useuris, --metauris
Include metadata in output (default=–useuris)
- -im, --importmap <importmap>
Import mapping file
- --log_level <log_level>
Logging level (default=WARNING)
- Options
CRITICAL | ERROR | WARNING | INFO | DEBUG
- --mergeimports, --no-mergeimports
Merge imports into source file (default=mergeimports)
Arguments
- YAMLFILE
Required argument