Standard RDF
Export a CGMES model as N-Triples or Turtle with every literal typed from the profile, so it loads in any RDF toolchain and passes ENTSO-E's SHACL shapes.
CIM/XML is not RDF a general parser can read: rdf:parseType="Statements" is not RDF syntax, rdf:ID="_<uuid>" denotes urn:uuid:<uuid> rather than a document fragment, and no value carries a datatype. ENTSO-E's CGMES 3.0 SHACL shapes constrain 3,137 properties by sh:datatype (2,871 of them xsd:float), so an untyped graph fails all of them.
cim-kit exports standard RDF with every literal typed from the profile.
Exporting#
use cim_kit::prelude::*;
use cim_kit::cgmes3::SCHEMA;
use cim_kit::rdf::{RdfOptions, Syntax};
fn main() -> cim_kit::Result<()> {
let grid = Dataset::load_dir(SCHEMA, "MicroGrid-BE")?;
// One profile's graph, as a SHACL engine wants it.
let eq = SCHEMA.profile_by_keyword("EQ").expect("the EQ profile");
let turtle = cim_kit::rdf::to_string(
&grid,
&RdfOptions::new(Syntax::Turtle).profiles(eq.mask()),
)?;
print!("{turtle}");
Ok(())
}<urn:uuid:17086487-56ba-4979-b8de-064025a6b4da>
a cim:ACLineSegment ;
cim:ACLineSegment.r "2.2"^^xsd:float ;
cim:ConductingEquipment.BaseVoltage <urn:uuid:a7f1d8de-d658-428a-821b-3a5ae5965fd1> ;
cim:Equipment.aggregate "false"^^xsd:boolean ;
cim:IdentifiedObject.name "BE-Line_1" ;
eu:IdentifiedObject.shortName "BE-L_1" .From a shell:
cim rdf MicroGrid-BE/ --out graphs/ # a Turtle graph per profile with data
cim rdf MicroGrid-BE/ --out graphs/ --ntriples # for piping into a validator
cim rdf MicroGrid-BE/ --out graphs/ --merged # the whole model in one graphThe mapping#
| CIM | RDF |
|---|---|
| Object with a UUID identifier | IRI urn:uuid:<uuid> — 61970-552's own identification rule |
| Object with a non-conforming identifier | Blank node, or an IRI under RdfOptions::base |
| Class | rdf:type <namespace><ClassName> |
| Attribute | Predicate <namespace><Class.attr> |
| Primitive value | Literal typed by Primitive::xsd_datatype |
CIM datatype (Resistance, …) | Literal of the primitive it serializes as |
| Enumeration | IRI <namespace><Enum.literal> |
| Association | IRI of the target object |
Compound (rdf:parseType="Resource") | Typed blank node with its fields |
md:FullModel header | A resource with its md:Model.* properties |
Datatypes follow the published shapes: CIM Float is xsd:float (not xsd:double), and Money is xsd:decimal, written without an exponent. Header properties are typed from the generated Header AP vocabulary: md:Model.created is xsd:dateTime, md:Model.version xsd:integer, md:Model.profile xsd:anyURI.
Export is per profile#
A profile constrains a reference's target to the classes it declares — the State Variables shapes allow SvStatus.ConductingEquipment to point only at a CsConverter or VsConverter — so a merged graph validated against them reports violations no instance file has. A profile mask therefore produces what that profile's instance file would:
- the same slice of objects and attributes as the CIM/XML writer;
- the same element class (an SSH graph types an
ACLineSegmentascim:Equipment); - only the
md:FullModelheaders of the files serving that profile; - no graph at all for a profile without data —
cim rdfnames skipped profiles on stderr.
Use --merged for the whole model in one graph, as for a triple store.
A file that serves several profiles is one graph#
In CGMES 2.4.15, Equipment, Operation and ShortCircuit travel in one file and share one EquipmentProfile shape. Ask for them together:
cim rdf model/ --profile EQ --profile OP --profile SC --out graphs/ # graphs/EQ_OP_SC.ttlFrom the library it is a mask, the same one write_profiles takes:
# use cim_kit::prelude::*;
# use cim_kit::cgmes3::SCHEMA;
# use cim_kit::rdf::{RdfOptions, Syntax};
# fn main() -> cim_kit::Result<()> {
# let grid = Dataset::load(SCHEMA, ["EQ.xml"])?;
let mask = ["EQ", "OP", "SC"]
.iter()
.filter_map(|k| SCHEMA.profile_by_keyword(k))
.fold(0, |acc, p| acc | p.mask());
let turtle = cim_kit::rdf::to_string(&grid, &RdfOptions::new(Syntax::Turtle).profiles(mask))?;
# Ok(()) }Checked by an engine, not by assertion#
cargo xtask shacl exports each profile through cim rdf and validates it with pyshacl against ENTSO-E's published shapes, in CI. A profile without data is reported as no data, and a run that validates nothing fails.
Every profile that carries data, in every published CGMES 3.0 conformity model (RealGrid included), conforms. The remaining findings are in the models: every SSH file writes <cim:Equipment rdf:about="…"> carrying only inService, while the SSH shapes require IdentifiedObject.mRID. The export reproduces that faithfully.
CGMES 2.4.15 is exported but not shape-validated: its published shapes are invalid SHACL (see Conformance).
The crate does not run SHACL itself; choose the engine. Reading RDF back is not supported — CIM/XML is the exchange format.