← Back to Skills Marketplace
fisa712

Knowledge Graph - Mapping Dsl Builder

by Muhammad Asif · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
37
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install mapping-dsl-builder
Description
Generate declarative mapping rules that transform structured data sources into graph triples or nodes using a domain-specific mapping language similar to R2RML.
README (SKILL.md)

Mapping DSL Builder

Generate declarative mapping rules for transforming data into graph structures.

This skill creates domain-specific language (DSL) mappings that define how data fields from structured sources such as databases, CSV files, JSON, or APIs should be transformed into nodes, relationships, and triples for graph databases or knowledge graphs. The mapping language functions similarly to R2RML, the standard for relational-to-RDF mappings.

Quick Start

Use When

  • Defining mappings between structured datasets and graph models
  • Creating declarative transformation rules
  • Converting relational schemas into RDF triples
  • Building graph ingestion mapping specifications
  • Generating reusable data-to-graph mapping configurations
  • Standardizing ETL transformation definitions

Inputs

  • Source schema definitions (database, CSV, JSON, API)
  • Entity type specifications
  • Column/property definitions
  • Foreign key relationships
  • Identifier specifications
  • Mapping rules and transformations
  • Target graph schema

Outputs

  • Custom Mapping DSL specifications
  • R2RML (RDF Mapping Language) definitions
  • YAML mapping configurations
  • JSON mapping specifications
  • Property graph mappings
  • Executable mapping configurations
  • Data transformation documentation

Example

Input Database Schema:

CREATE TABLE employee (
  id INT,
  name VARCHAR(255),
  email VARCHAR(255),
  company_id INT
);

CREATE TABLE company (
  id INT,
  name VARCHAR(255),
  industry VARCHAR(100)
);

Generated Mapping DSL:

mapping: EmployeeMapping
version: 1.0

source:
  type: database
  table: employee
  connection: postgresql://localhost/company_db

entity:
  type: Person
  identifier: id
  uri_template: "http://example.org/person/{id}"

properties:
  - source: name
    target: http://xmlns.com/foaf/0.1/name
    type: string
  - source: email
    target: http://xmlns.com/foaf/0.1/mbox
    type: string

relationships:
  - name: WORKS_AT
    source: company_id
    target: Company
    target_identifier: id

Mapping DSL Architecture

1. Source Definition

Purpose: Specify where data comes from

Types Supported:

  • Database - SQL databases (PostgreSQL, MySQL, Oracle)
  • CSV - Comma/delimiter-separated files
  • JSON - JSON files or documents
  • API - REST API endpoints
  • Streaming - Real-time data streams

Configuration:

source:
  type: database|csv|json|api|stream
  connection_string: connection_details
  table_or_location: specification
  format: format_options

2. Entity Mapping

Purpose: Define how records map to graph entities

Components:

  • Type - Entity type/label (Person, Organization, etc.)
  • Identifier - Column(s) that uniquely identify records
  • URI Template - Pattern for generating entity URIs
  • Properties - Attributes to include

Configuration:

entity:
  type: EntityType
  identifier: id_column
  uri_template: "http://example.org/type/{id}"
  namespace: http://example.org/

3. Property Mapping

Purpose: Map source attributes to graph properties

Details:

  • Source column name
  • Target property URI
  • Data type
  • Transformations (optional)
  • Default values (optional)

Configuration:

properties:
  - source: database_column
    target: http://schema.org/propertyName
    type: string|integer|date
    transformation: function_name
    required: true|false

4. Relationship Mapping

Purpose: Define relationships between entities

Details:

  • Relationship name/type
  • Source column (foreign key)
  • Target entity
  • Cardinality
  • Direction

Configuration:

relationships:
  - name: RELATIONSHIP_TYPE
    source: foreign_key_column
    target: TargetEntity
    target_identifier: target_id
    cardinality: "1..1"|"1..*"|"*..1"|"*..*"
    direction: forward|backward|bidirectional

Mapping Patterns

Database Mapping Pattern

Pattern: Map relational table to graph entity

source:
  type: database
  table: employee
relationships:
  - name: WORKS_AT
    source: company_id (foreign key)
    target: Company entity

CSV Mapping Pattern

Pattern: Map CSV columns to graph properties

source:
  type: csv
  file: data/employees.csv
  delimiter: ","
entity:
  identifier: person_id (unique column)
properties:
  - source: name
    target: foaf:name

JSON Mapping Pattern

Pattern: Map JSON properties to graph structure

source:
  type: json
  path: $.employees[*]
entity:
  identifier: $.id
properties:
  - source: $.name
    target: http://example.org/name

Nested Object Mapping Pattern

Pattern: Handle nested structures

source:
  type: json
  path: $.employees[*]
relationships:
  - name: HAS_ADDRESS
    source: $.address (nested object)
    target: Address
    inline: true

Output Formats

Custom Mapping DSL

mapping: PersonMapping
version: 1.0

source:
  type: csv
  file: people.csv

entity:
  type: Person
  identifier: person_id

properties:
  - source: name
    target: foaf:name
  - source: email
    target: foaf:mbox

relationships:
  - name: WORKS_AT
    source: company_id
    target: Company

R2RML Format

@prefix rr: \x3Chttp://www.w3.org/ns/r2rml#> .
@prefix foaf: \x3Chttp://xmlns.com/foaf/0.1/> .
@prefix ex: \x3Chttp://example.org/> .

ex:EmployeeMapping a rr:TriplesMap ;
  rr:logicalTable [ rr:tableName "employee" ] ;
  rr:subjectMap [
    rr:template "http://example.org/person/{id}" ;
    rr:class foaf:Person
  ] ;
  rr:predicateObjectMap [
    rr:predicate foaf:name ;
    rr:objectMap [ rr:column "name" ]
  ] ;
  rr:predicateObjectMap [
    rr:predicate foaf:workplaceHomepage ;
    rr:objectMap [
      rr:parentTriplesMap ex:CompanyMapping ;
      rr:joinCondition [ rr:child "company_id" ; rr:parent "id" ]
    ]
  ] .

YAML Format

version: 1.0
mappings:
  - name: PersonMapping
    source:
      type: database
      table: person
    entity:
      type: Person
      id: person_id
    properties:
      name: name
      email: email_address
    relationships:
      works_at:
        target: Company
        foreign_key: company_id

Data Type Support

Supported Types

  • string - Text data
  • integer - Whole numbers
  • decimal - Floating point numbers
  • boolean - True/false values
  • date - Date values (YYYY-MM-DD)
  • datetime - Date and time
  • uri - Uniform resource identifiers
  • custom - User-defined types

Type Mapping

Relational → RDF Type Mapping
INTEGER → xsd:integer
VARCHAR → xsd:string
DATE → xsd:date
DECIMAL → xsd:decimal
BOOLEAN → xsd:boolean

Transformation Functions

Built-in Transformations

concat(field1, field2)    - Concatenate fields
uppercase(field)          - Convert to uppercase
lowercase(field)          - Convert to lowercase
substring(field, 0, 5)    - Extract substring
replace(field, old, new)  - Replace values
regex(field, pattern)     - Regex matching
split(field, delimiter)   - Split string
trim(field)               - Remove whitespace

Execution Steps

  1. Analyze Source Schema – Detect structure and data types
  2. Identify Entities – Find key identifiers
  3. Detect Relationships – Recognize foreign keys
  4. Map Properties – Associate columns to properties
  5. Generate URIs – Create entity identifiers
  6. Define Transformations – Apply any conversions
  7. Validate Mapping – Check for consistency
  8. Generate Output – Produce mapping specifications

Recommended Libraries

  • Mapping Processing: rdflib, r2rml-processor, morph-kgc
  • DSL Generation: pyparsing, lark, textx
  • Schema Analysis: sqlalchemy, pandas, jsonschema
  • RDF Generation: rdflib, sparql-client
  • YAML/Config: pyyaml, toml, configparser
  • Database: sqlalchemy, psycopg2, pymongo

Best Practices

✓ Use consistent URI templates
✓ Choose meaningful identifiers
✓ Document mapping rationale
✓ Normalize property names
✓ Handle missing values explicitly
✓ Test mappings with sample data
✓ Version mapping configurations
✓ Document transformations
✓ Validate schemas before mapping
✓ Keep mappings reusable

Integration with Downstream Skills

Generated mappings are used by:

  • ETL Pipeline Generator – Execute mappings in pipelines
  • JSON to Triples Converter – Transform JSON using mappings
  • CSV Graph Loader Generator – Load CSV with defined mappings
  • Graph Schema Validation – Validate mapped data
  • Graph Constraint Generator – Apply constraints to mapped data

References

See mapping-patterns.md for detailed mapping design patterns and example-mappings.md for complete real-world examples.


Version: 1.0.0

Usage Guidance
Safe to install for generating mapping specifications. Treat connection strings, bearer tokens, API keys, and database credentials as sensitive if you include them in mappings, and prefer placeholders or secret references instead of embedding live secrets in generated files.
Capability Tags
requires-oauth-tokenrequires-sensitive-credentials
Capability Assessment
Purpose & Capability
The stated purpose is to generate declarative mappings from structured data into graph/RDF-style representations, and the files match that purpose with guidance, examples, and a Python builder that formats in-memory mapping objects into DSL, R2RML, YAML, or JSON.
Instruction Scope
Runtime instructions are scoped to mapping design, schema analysis, property/relationship mapping, output formats, and examples; no prompt-injection, role override, covert execution, or unrelated agent-control instructions were found.
Install Mechanism
The package contains markdown documentation and one Python helper script; there are no install hooks, package-manager scripts, dependency-install commands, or automatic execution mechanisms.
Credentials
Metadata tags mention OAuth tokens and sensitive credentials, and examples discuss database/API connection details, but the artifacts use these as mapping configuration fields and placeholders rather than reading local secrets or making outbound connections.
Persistence & Privilege
No persistence, background workers, privilege escalation, local profile/session access, file writes, deletion, exfiltration, or network calls were found in the artifacts.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install mapping-dsl-builder
  3. After installation, invoke the skill by name or use /mapping-dsl-builder
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of Mapping DSL Builder: a skill to generate mapping rules for transforming structured data into graph representations. - Supports input from databases, CSV, JSON, and APIs to define graph entities, properties, and relationships. - Outputs mapping specifications in custom DSL, R2RML, YAML, or JSON formats. - Handles property and relationship mapping, including data type conversion and transformation functions. - Provides example patterns for mapping from relational tables, CSV files, JSON, and nested objects. - Designed to create reusable, declarative mapping configurations for ETL and data-to-graph transformation tasks.
Metadata
Slug mapping-dsl-builder
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Knowledge Graph - Mapping Dsl Builder?

Generate declarative mapping rules that transform structured data sources into graph triples or nodes using a domain-specific mapping language similar to R2RML. It is an AI Agent Skill for Claude Code / OpenClaw, with 37 downloads so far.

How do I install Knowledge Graph - Mapping Dsl Builder?

Run "/install mapping-dsl-builder" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Knowledge Graph - Mapping Dsl Builder free?

Yes, Knowledge Graph - Mapping Dsl Builder is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Knowledge Graph - Mapping Dsl Builder support?

Knowledge Graph - Mapping Dsl Builder is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Knowledge Graph - Mapping Dsl Builder?

It is built and maintained by Muhammad Asif (@fisa712); the current version is v1.0.0.

💬 Comments