Netbeheer-Nederland / cgmes-to-linkml

Generate a LinkML schema from a CIM RDF schema (conforming IEC 61970-501).
Apache License 2.0
1 stars 0 forks source link

cimrdfs2linkml

Generates a LinkML schema from a CIM RDF Schema (as per IEC 61970-501).

[!NOTE] Currently only RDFS 2020 serializations of the CGMES 3.0.0 profiles are supported. This is because of assumptions about the profile metadata baked into the code.

Installation and Running

Install the dependencies, preferably using poetry, and make sure the (virtual) environment you're can find the cimrdfs2linkml package (e.g. by extending $PYTHONPATH).

Then, to run the script, simply run:

$ cimrdfs2linkml /path/to/input_schema.rdf -o /path/to/output_schema.yaml

If you omit the -o option, the target schema will be written to ./out.yaml. For further usage help you can provide the --help flag.

Mapping

The CIM RDF Schema distinguishes between several stereotypes of classes. The following are handled by cimrdfs2linkml:

[!NOTE] CIM data types each consist of a unit symbol, unit mulitplier and value. For each such data type the symbol and multiplier are fixed (cims:isFixed) to some enum value. This fixed value is currently ignored.

Furthermore, each RDF property pertaining to some class is mapped to a LinkML attribute of that class.

[!NOTE] As is made clear by the class name prefix in all property URIs, all properties are tightly coupled to classes. For that reason all properties are mapped to class attributes rather than top-level slots, i.e. no top-level slots are generated.

Implementation Notes

For the quick development of this script the library xmltodict is used. This works since the IEC 61970-501 spec demands the use of an XML serialization of the schema, but proper RDF parsing (and querying) using something like rdflib has benefits and probably needs to be done in the future.