Resource Description Framework¶
This module provides a comprehensive framework for parsing, analyzing, and rendering RDF (Resource Description Framework) schemas, with a focus on the Common Information Model (CIM) and related standards. It enables the transformation of RDF-based ontologies into strongly-typed C#, Java(experimental) and Python(experimental) classes and enumerations, supporting advanced code generation and schema management scenarios.
Key Capabilities¶
-
RDF Schema Parsing
- Extracts namespaces, headers, classes, attributes, data types, enumerations, and concrete classes from RDF/XML files.
- Supports detailed introspection of RDF graphs using the dotNetRDF library.
-
Schema Analysis
- Analyzes RDF classes, attributes, and data types to determine their render requirements and C#, Java(experimental) and Python(experimental) type mappings.
- Distinguishes between primitive types, references, enumerations, and concrete classes.
-
Code Generation
- Renders C#, Java(experimental) and Python(experimental) classes and enumerations from RDF schema definitions using Scriban templates.
- Supports extensible and customizable code generation pipelines.
-
Schema Management
- Provides a domain service for loading, updating, and managing RDF schema representations.
- Enables updating of schema elements (classes, attributes, data types, enumerations) in a consistent and type-safe manner.
-
Ontology Hierarchy Support (experimental)
- Support for ontology graph parsing and hierarchy building, including class inheritance and property relationships.
Tool¶
The ModelGenerator
is a command-line tool for generating code from RDF schema files (such as CGMES or CIM). It supports multiple target languages (CSharp, Java, Python) and is highly configurable via command-line options.
Usage¶
You can use a published executable
GridLab.PSSX.ModelGenerator.exe [OPTIONS]
Example
GridLab.PSSX.ModelGenerator.exe \
--input CGMES_Schema/CGMES_3.0.0 \
--language CSharp \
--mergeSchemas true \
--profileName IEC61970 \
--namespace Profiles.IEC61970 \
--version 3.0.0
Common Options:
Option | Description |
---|---|
-i, --input | Directory containing RDF files |
-p, --rdfFilePattern | File pattern to search for RDF files (default: *.rdf) |
-f, --inputFile | Single RDF file to process |
-o, --output | Output directory (defaults to executable location) |
-m, --mergeSchemas | Merge all schemas and their attributes |
--profileName | Name of the profile for generated classes (if schemas are merged) |
--version | Version for generated classes (if schemas are merged) |
--namespace | Namespace for generated classes (if schemas are merged) |
--overwriteFiles | Overwrite existing files in the output directory |
--classTemplatePath | Path to custom Scriban template for classes |
--enumerationTemplatePath | Path to custom Scriban template for enumerations |
-l, --language | Target language: CSharp, Java, Python |
-w, --logWarnings | Log warnings for missing/malformed schema elements |
-d, --includeDeprecated | Include deprecated classes/properties |
--namespaces | Allowed namespace prefixes (comma-separated) |
--allowedClassNames | Allowed class names (comma-separated) |
--allowedAttributeNames | Allowed attribute names (comma-separated) |
--allowedEnumerationNames | Allowed enumeration names (comma-separated) |
--ignoreUnknownTypes | Ignore unknown/unsupported RDF types instead of throwing |
--inferLabels | Infer missing labels from URIs |
--normalizeLiterals | Normalize literal values |
--throwOnUnknownTypes | Treat unknown/unsupported types as errors |
--inferPropertyTypes | Infer missing property types from context |
--normalizeNames | Normalize property/class names (e.g., PascalCase, SnakeCase) |
--reservedKeywordSuffix | Suffix to append to reserved keywords |
--includeAutoGeneratedComment | Include an auto-generated comment in generated files |
To see all options and their descriptions, run:
GridLab.PSSX.ModelGenerator.exe --help