Skip to content

fix(#93): make dprod.jsonld a proper JSON-LD context; split out ontology to dprod-ontology.jsonld#135

Closed
jgeluk wants to merge 1 commit intodevelopfrom
fix/93-jsonld-context
Closed

fix(#93): make dprod.jsonld a proper JSON-LD context; split out ontology to dprod-ontology.jsonld#135
jgeluk wants to merge 1 commit intodevelopfrom
fix/93-jsonld-context

Conversation

@jgeluk
Copy link
Member

@jgeluk jgeluk commented Aug 27, 2025

Summary

  • dprod.jsonld is now a proper JSON-LD context document — it contains only an @context object with namespace prefixes, DPROD term mappings (classes and properties extracted from the ontology), and id/type aliases for @id/@type.
  • dprod-ontology.jsonld is the OWL ontology serialized as JSON-LD (what dprod.jsonld previously was).
  • All example @context references updated from dprod-context.jsonld to dprod.jsonld.
  • Other generated artifacts (dprod-all.jsonld, *.ttl, *.rdf, shapes) remain unchanged.

Resolves #93

What changed

  • Generator (spec-generator/main.py):
    • New generate_jsonld_context() function extracts all DPROD term names from the ontology graph and maps them to dprod: prefixed terms.
    • Context includes "id": "@id" and "type": "@type" aliases for convenience.
    • Writes the context to dist/dprod.jsonld.
    • Writes the ontology dump to dist/dprod-ontology.jsonld.
    • Removes dprod-context.jsonld (no longer needed).
  • Spec template (respec/template.html):
    • Download links: added "DPROD JSON-LD Context" (dprod.jsonld) and "DPROD Ontology — JSON-LD" (dprod-ontology.jsonld).
    • Inline example @context updated to dprod.jsonld.
  • Examples: All @context references changed from dprod-context.jsonld to dprod.jsonld.
  • Tests (tests/test_context.py):
    • dprod.jsonld is a pure context (only @context key, includes prefixes and term mappings).
    • dprod-ontology.jsonld contains @graph.
    • Minimal JSON-LD instance using the context expands to correct DPROD triples via PyLD.
    • Bare id/type aliases resolve correctly.
  • CLAUDE.md: Updated documentation to reflect new file layout.

How to consume

Reference the context in JSON-LD instance documents:

"@context": "https://www.omg.org/spec/DPROD/dprod.jsonld"

Verification

  • Local build: Python 3.13, .venv
  • Test run: 4 tests passed, 0 failures

- dprod.jsonld is now a proper JSON-LD context document with term
  mappings extracted from the ontology (classes and properties),
  namespace prefixes, and id/type aliases for @id/@type.
- The OWL ontology JSON-LD serialization moves to dprod-ontology.jsonld.
- All example @context references updated to use dprod.jsonld.
- Added tests validating context structure, ontology structure,
  term resolution via PyLD, and id/type alias expansion.

Resolves: #93
@jgeluk jgeluk force-pushed the fix/93-jsonld-context branch from 39171b7 to 14b6756 Compare February 18, 2026 20:38
@jgeluk
Copy link
Member Author

jgeluk commented Feb 18, 2026

I rebased this branch onto current develop and reworked the changes. Here is what changed compared to the original PR:

Rebased onto develop

The branch was significantly behind develop (missing 20+ commits including license change to CC-BY-4.0, copyright updates, tech stack upgrade, CONTRIBUTING.md, CLAUDE.md, etc.). It is now up to date.

Removed dprod-context.jsonld

The earlier work on develop (for issue #90) had introduced a separate dprod-context.jsonld as the standalone context while keeping dprod.jsonld as the ontology dump. This PR consolidates that:

  • dprod.jsonld → proper JSON-LD context (replaces both the old ontology dump and the interim dprod-context.jsonld)
  • dprod-ontology.jsonld → OWL ontology serialized as JSON-LD (what dprod.jsonld previously was)

Since nobody is consuming dprod.jsonld as an ontology dump, this is a safe rename.

Added id/type aliases

The generated context now includes "id": "@id" and "type": "@type", matching the convention already used throughout the examples (bare id and type instead of @id and @type).

Updated all references

All example files, the ReSpec template inline example, and the download links now point to dprod.jsonld for the context. The download section in the spec now lists both "DPROD JSON-LD Context" (dprod.jsonld) and "DPROD Ontology — JSON-LD" (dprod-ontology.jsonld).

Expanded tests

Added a fourth test (test_context_id_type_aliases) that verifies bare id/type resolve correctly. Updated the existing tests to use the current OMG namespace (https://www.omg.org/spec/DPROD/) instead of the old ekgf.github.io one.

Squashed into a single commit

The three original commits were squashed into one clean commit on top of develop.

@jgeluk jgeluk changed the title Fix for issue #93 jsonld context fix(#93): make dprod.jsonld a proper JSON-LD context; split out ontology to dprod-ontology.jsonld Feb 18, 2026
@jgeluk
Copy link
Member Author

jgeluk commented Feb 25, 2026

Closing as superseded: the fix for issue #93 is already on develop (commit 3fefa04 / merge from ballot/3). Develop uses dprod-context.jsonld for the context and dprod.jsonld for the ontology; this PR inverts the naming (dprod.jsonld = context, dprod-ontology.jsonld = ontology). The split (context vs ontology) is done; no need to merge this PR unless we want to adopt this naming convention.

@jgeluk
Copy link
Member Author

jgeluk commented Feb 25, 2026

Superseded by the fix already on develop (see issue #93). The context/ontology split is done there via dprod-context.jsonld; this PR's naming is an alternative. Closing to avoid duplicate work.

@jgeluk jgeluk closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the @context is not a context but an ontology

1 participant