feat: schema datatype annotations in N-Quads export#46
Merged
Conversation
added 2 commits
June 11, 2026 15:20
When the export schema declares an xsd:type for a property, literals get the datatype annotation: "1.5"^^<http://www.w3.org/2001/XMLSchema#float>. - xsd:string keys stay plain literals (RDF 1.1 default type) - xsd:anyURI keys (e.g. Model.DependentOn) are references — excluded, they keep IRI handling - a key with a declared datatype is a literal by schema, so the check precedes the UUID heuristic — fixes IdentifiedObject.mRID being mis-exported as a urn:uuid reference instead of a string literal - without a schema, output is unchanged (no annotations) Tests: typed floats, plain strings, mRID-as-literal, anyURI references, no-schema unchanged, polars/pandas parity, and rdflib validation — the export parses as N-Quads and typed literals round-trip with the right python type.
Every urn:uuid object IRI must resolve to a subject in the dataset, except references the source data itself knows are dangling — the unresolved set is cross-checked against get_dangling_references() (boundary objects, Model.DependentOn to other profiles).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31 — the datatype support that was keeping it open.
What
When the export schema declares an
xsd:typefor a property, N-Quads literals carry the datatype:Rules
xsd:stringkeys → plain literals (RDF 1.1 default type, no annotation bloat)xsd:anyURIkeys (e.g.Model.DependentOn) are references, not typed literals — they keep IRI handling (<urn:uuid:...>); caught by a test after the first implementation turned them into literalsIdentifiedObject.mRIDbeing mis-exported as aurn:uuidreference instead of the string literal it isApplies to both engines (pandas + polars) via the shared
nquads_utils.build_key_metadata/make_object.Tests
TestNquadsDatatypes: typed floats, strings stay plain, mRID-as-literal, anyURI stays IRI, no-schema output unchanged, polars/pandas parity, and rdflib validation — the export parses as N-Quads (rdflib.Dataset), statement count matches, and typed literals round-trip withdatatype == XSD.floatand pythonfloatvalues.Full suite: 154 passed, 44 skipped, 1 known xfail.