Skip to content

mdld-js/mdld-shapes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 MDLD Shapes Catalog

SHACL MDLD Coverage

Self-validating semantic documentation - Author SHACL constraints in human-readable Markdown while maintaining full W3C standards compliance

πŸš€ What This Is

The MDLD Shapes catalog is a breakthrough proof-of-concept that demonstrates how MDLD (Markdown Linked Data) enables semantic knowledge authoring where:

  • πŸ“š Documentation = Validation Rules - No more separation between human docs and machine validation
  • 🎯 W3C Standards Aligned - Full SHACL specification compliance with RDF export
  • πŸ”§ Production Ready - Comprehensive constraint catalog with clean ontology separation
  • πŸ“– Educational - Learn SHACL through interactive, self-documenting examples

✨ Key Features

πŸŽͺ Comprehensive Constraint Coverage

  • 23 constraint types with working examples
  • 75% SHACL specification coverage including value types, cardinality, ranges, patterns
  • Live validation with expected violation counts
  • Real-world use cases from e-commerce, healthcare, finance

🎨 Innovative MDLD Syntax

# Class Constraint {=sh:class .class:Constraint label}
> Expects each value to be an instance of a specific class {comment}

**Employee manager must be a Person instance** {=#managerClass .sh:PropertyShape message} 
requires the [manager] {+ex:manager ?sh:path} property to be an instance of [Person] {+ex:Person ?sh:class}.

πŸ› οΈ Complete Toolchain

  • ig-cli - Command-line validation and querying
  • Intelligraphs - Visual graph exploration
  • RDF Export - Standard Turtle/JSON-LD output
  • SPARQL Support - Query your validation rules

πŸ“Š Catalog Statistics

  • Sidecar organization - Ontology (.md) and demo (.demo.md) files in same folders
  • 23 constraint types with working examples and test data
  • 75% SHACL specification coverage including value types, cardinality, ranges, patterns
  • 4 targeting mechanisms for flexible validation
  • Clean ontology assembly - 0 violations (production-ready)
  • Demo assembly - 103+ violations (development/testing)

πŸš€ Quick Start

Option 1: Clone and Run Locally

git clone https://github.com/davay42/mdld-shapes.git
cd mdld-shapes
curl -O https://app.intelligraphs.com/ig-cli.js
chmod +x ig-cli.js
mv ig-cli.js /usr/local/bin/ig-cli

# Explore the catalog
ig-cli stats
ig-cli validate ./constraints/class.demo.md
ig-cli get entity https://mdld.js.org/shacl/example/class/InvalidEmployee

Option 2: View with Intelligraphs

πŸ‘‰ Open in Intelligraphs App

πŸ“ Repository Structure

Sidecar Organization

The catalog uses a sidecar file organization where ontology and demo content are kept together in the same folders:

mdld-shapes/
β”œβ”€β”€ constraints/
β”‚   β”œβ”€β”€ class.md              # Ontology: constraint definition
β”‚   β”œβ”€β”€ class.demo.md         # Demo: test data and violations
β”‚   β”œβ”€β”€ datatype.md           # Ontology
β”‚   β”œβ”€β”€ datatype.demo.md      # Demo
β”‚   └── ...
β”œβ”€β”€ targeting/
β”‚   β”œβ”€β”€ targetClass.md        # Ontology
β”‚   β”œβ”€β”€ targetClass.demo.md   # Demo
β”‚   └── ...
β”œβ”€β”€ index.md                 # Main catalog (links to both)
β”œβ”€β”€ index.ontology.md        # Ontology-only catalog
β”œβ”€β”€ index.demo.md            # Demo-only catalog
└── assemble.js              # Unified assembly script (all/ontology/demo modes)

Assembly Outputs

  • shacl.md - Complete catalog (ontology + demo data) - 162+ violations
  • shacl-ontology.md - Clean ontology only - 0 violations (production-ready)
  • shacl-demo.md - Demo data only - 103+ violations (development/testing)

Assembly Script

  • assemble.js - Automatically assembles all 3 catalogs:
    node assemble.js  # Assembles all: shacl.md, shacl-ontology.md, shacl-demo.md

πŸ“š Explore the Catalog

Complete guide to all SHACL constraints and targeting mechanisms

πŸ”§ Constraints

Validation rules organized by category:

  • Value Type - Class, DataType, NodeKind
  • Cardinality - Min/Max count validation
  • String-based - Patterns, Length, Language
  • Logical - AND, NOT constraints
  • Range - Numeric/Date boundaries
  • Advanced - Node, Qualified, JavaScript

Select which nodes to validate:

  • Target Class - Validate all instances of a type
  • Target Node - Validate specific nodes
  • Target Subjects/Objects - Validate by property relationships

πŸ’‘ Usage Examples

Assemble the Catalog

# Assemble all catalogs automatically
node assemble.js
# Produces: shacl.md, shacl-ontology.md, shacl-demo.md

Validate Data Quality

# Test individual demo files
ig-cli validate ./constraints/class.demo.md
ig-cli validate ./targeting/targetClass.demo.md

# Validate assembled demo catalog
ig-cli validate ./shacl-demo.md

# Validate clean ontology (should have 0 violations)
ig-cli validate ./shacl.md

# Get detailed entity information
ig-cli get entity https://mdld.js.org/shacl/example/class/InvalidEmployee

Query Validation Rules

# List all SHACL shapes
ig-cli shapes

# Find all constraint types
ig-cli types | grep "Constraint"

# Export to standard RDF formats
ig-cli dump --format=ttl > shapes.ttl

🎯 Real-World Applications

E-commerce

# Product validation with price ranges and required fields
{+schema:Product ?sh:targetClass}
**Product price must be between $10.00 and $1000.00** {sh:message}

Healthcare

# Patient data validation with HIPAA compliance
{+medical:Patient ?sh:targetClass}
**Patient records must have valid medical IDs** {sh:message}

Finance

# Transaction validation with audit requirements
{+financial:Transaction ?sh:targetClass}
**All transactions must be auditable** {sh:message}

πŸ” Validation Results

βœ… Working Constraints (75%)

  • Value Type Constraints βœ…
  • Cardinality Constraints βœ…
  • String Constraints βœ…
  • Range Constraints βœ…
  • Logical Constraints (AND/NOT) βœ…
  • Targeting Mechanisms βœ…

⚠️ In Development (25%)

  • Logical OR/XONE constraints
  • Property path constraints
  • JavaScript/SPARQL constraints
  • Advanced qualified constraints

πŸ›£οΈ Roadmap

  • Complete 100% SHACL specification coverage
  • Performance optimization for large datasets
  • Enhanced error reporting and debugging
  • Integration with popular RDF stores
  • Visual constraint editor
  • Automated constraint generation from schemas

🧹 Current State

Recent Changes

  • βœ… Sidecar organization - Restructured from separate ontology/demo folders to sidecar files (.md + .demo.md)
  • βœ… Clean ontology - Assembly produces 0 violations, safe for production use
  • βœ… Fixed RDF list collisions - Unique identifiers prevent assembly conflicts
  • βœ… Separated concerns - Ontology definitions and test data now properly separated

File Organization

  • Main files (.md) - Ontology definitions, syntax patterns, use cases
  • Demo files (.demo.md) - Test data, shapes, expected violations, validation commands
  • Assembly scripts - Separate scripts for ontology-only and demo-only assemblies
  • Index files - Different entry points for different assembly needs

Validation Status

  • βœ… Ontology assembly - 0 violations (clean, production-ready)
  • βœ… Demo assembly - 103+ violations (comprehensive test coverage)
  • βœ… Individual demos - All demo files validate correctly
  • βœ… Complete assembly - 162+ violations (combined reference)

Development Setup

git clone https://github.com/davay42/mdld-shapes.git
cd mdld-shapes
# Add your constraint examples
# Test with ig-cli validate
# Submit pull request

πŸ“– Learn More


🎯 Transform how you author semantic validation rules - Write once, validate everywhere, learn continuously.

About

Shapes language catalog

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors