A Python tool that processes RDF OWL ontology files and generates comprehensive documentation in multiple formats, including Mermaid ER diagrams showing classes, properties with datatypes, and their relationships.
This tool helps you visualize and document your RDF OWL ontology by:
- Processing OWL ontology files (Turtle, RDF/XML, JSON-LD, N-Triples)
- Extracting classes, object properties, and datatype properties
- Generating human-readable Markdown documentation
- Creating UML diagrams (PlantUML and Mermaid formats)
- Exporting structured formats (JSON, YAML) for programmatic analysis
- Visualizing class hierarchies and property relationships
- Clone or download this repository
- Install dependencies:
pip install -r requirements.txtTo test the tool with the included example OWL file:
# Using the virtual environment's Python
python main.py -i examples/owl-uwp-oslo-cp.ttl -o ./schema-docs
# Or activate the virtual environment first
source venv/bin/activate
python main.py -i examples/owl-uwp-oslo-cp.ttl -o ./schema-docspython main.py --input ./ontology.ttl --output-dir ./schema-docspython main.py \
--input ./ontology.ttl \
--input-format turtle \
--output-dir ./schema-docs \
--formats text uml json yaml--input,-i: Path to input RDF/OWL file (required)--input-format,-f: Input file format ('turtle', 'xml', 'json-ld', 'nt', or auto-detect if not specified)--output-dir,-o: Output directory for generated documentation (default: ./schema-docs)--formats: Output formats to generate (default: text, uml, json, yaml)- Options:
text,uml,json,yaml - Can specify multiple:
--formats text uml json
- Options:
Process the included example OWL file:
python main.py -i examples/owl-uwp-oslo-cp.ttl -o ./schema-docsProcess a Turtle OWL file:
python main.py -i ontology.ttl -o ./docsProcess an RDF/XML file:
python main.py -i ontology.rdf -f xml --formats text umlGenerate all formats:
python main.py -i ./ontology.ttl --formats text uml json yamlThe tool generates the following files in the output directory:
-
schema_documentation.md- Comprehensive Markdown documentation- Ontology overview
- Class-by-class documentation
- Property listings with types and ranges
- Relationship mappings
- Index of all classes and properties
-
schema_diagram.puml- PlantUML diagram file- Can be rendered using PlantUML tools or online viewer
- Shows classes as entities with relationships
-
schema_diagram.mmd- Mermaid diagram file- Can be rendered in Markdown viewers, GitHub, or Mermaid Live Editor
- Entity-relationship diagram format showing classes, properties, and relationships
-
schema.json- Structured JSON schema definition- Machine-readable format
- Suitable for programmatic analysis
-
schema.yaml- Structured YAML schema definition- Human-friendly structured format
- Easy to compare with other schemas
The repository includes an example OWL file in the examples/ directory:
examples/owl-uwp-oslo-cp.ttl- A sample OWL ontology for testing
You can use this file to test the tool:
python main.py -i examples/owl-uwp-oslo-cp.ttl -o ./schema-docs- Turtle (.ttl) - Default format, human-readable
- RDF/XML (.rdf, .owl) - XML-based RDF format
- JSON-LD (.jsonld) - JSON-based linked data format
- N-Triples (.nt) - Line-based RDF format
- OWL Class Extraction: Extracts all
owl:Classdeclarations - Property Analysis: Separates object properties and datatype properties
- Relationship Visualization: Shows subclass hierarchies and property domain/range relationships
- Multiple Domains: Handles properties with multiple domain classes
- Datatype Support: Shows XSD datatypes for datatype properties
- Multiple Output Formats: Text, UML, JSON, YAML
- Currently focuses on OWL ontologies (SHACL support may be added later)
- Anonymous classes (owl:Restriction, owl:IntersectionOf) are not fully visualized
- Property chains are not visualized
- Individuals (owl:NamedIndividual) are ignored in diagram generation
Generate comprehensive documentation of your OWL ontology for:
- Team onboarding
- Ontology evolution tracking
- Integration planning
- Semantic mapping workshops
Use Mermaid diagrams to:
- Understand class hierarchies at a glance
- Identify property relationships between classes
- Review data type usage across properties
- Share visual representations with stakeholders
Issue: "No classes found in input file"
- Solution: Verify your file is a valid OWL ontology with
owl:Classdeclarations
Issue: "Invalid RDF format"
- Solution: Check that your file format matches the specified format, or let auto-detection work
Issue: "Properties not showing relationships"
- Solution: Ensure properties have
rdfs:domainandrdfs:rangedefined
This tool is designed to work with OWL ontologies. For improvements or bug reports, please contact the development team.
Internal use only.