Description
This enhancement proposal presents two use cases which suggest extending term definition semantics to also prefix-expanded terms.
As it is now the term definition semantics only apply during expansion to node dictionary keys which are exact matches to an extended term definition. Only the "@id" member is semantically meaningful when a term is used as a prefix.
A limited form of this proposal specific to "@container": "@list" can be found on the json-ld-api github
This enhancement is not targeted at 1.1 and as such does not make final syntactic proposals but focuses on describing the use cases for consideration. If the proposal is considered essentially sane then further experimentation is expected to yield more concrete suggestions.
1. Documentation JSON interchange format
A complex Javascript-based ecosystem exists with many semantically different places where documentation needs to be embedded and cross-referenced. HTML is too cumbersome and format such as Markdown is a convenient solution only in some situations, but requires source-code introspection and is not machine-readable.
A unified JSON interchange format is preferred which satisfies following criteria:
- Easy to write manually, with minimal boilerplate. The more boilerplate, the higher the threshold to writing docs.
- Programmatically manipulable. Complex array and other wrapper nestings make both programmatic introspection and emission cumbersome and errorprone.
- Has a generic underlying object model. Documentation evolves; it is useful to be able to identify sections globally and not just by their relative brittle position in a JSON document.
Any two of the criteria are easy to achieve with little effort. Criteria 3 suggests JSON-LD but there are shortcomings.
Let's consider a hypothetical function 'doTheThing' documentation block (with explanatory, self-referential bogus text content):
const doc = {
"name": "doTheThing",
"s:#name-0": [
"This is a generic section typically containing text.",
"The suffix fragment 'name-0' not just positions this section lexically after 'name'",
"but also gives this section a stable identity ('name-0') within the document."
""
"Sections are separated by empty strings.",
["Or alternatively as lists of lists."],
"",
"This section contains", { "d:text": "an external link" "d:href": "foo.org" }, ".",
],
"s:bulleted#name-1": [
"The first line of a named bullet list",
["Second line", { "d:text#ref-1": "with embedded named link", "d:href": "target.org" }],
],
"s:#name-3": [
"More text with an embedded unnamed numbered list", { "s:numbered": ["one", "two"] }
],
"arguments": {
"d:after": "name",
"some_arg": {}, "other_arg": {}
},
"s:#arguments-0": [
"More text which positioned after arguments section, with arguments",
"section itself explicitly positioned after 'name' section."
]
}
Criteria 1 is satisfied by relying on two principles: writer only needs to understand section (s:*
) primitives, and how the fragment is used for relative positioning and section identification.
Criteria 2 is satisfied by on one hand doc.name
and doc.arguments.some_arg
being intuitive to access and how numbered and bulleted list contents are flat, easily programmatically accessible and emittable arrays.
Criteria 3 is achievable by JSON-LD in the general case only if complex suffixes, specifically "@container": "@list" is supported:
{
"@context": {
"d": "http://example.org/doc/primitive/",
"s": { "@id": "http://example.org/doc/section/", "@container": "@list" }
}
}
As of now the default container type is @set, which loses both ordering and duplicates, both of which are critical. Necessitating the various suffixes to be explicitly declared in the @context loses generality.
A playground example demonstrating the set/list issue. Both "p" and "p:s" should yield list triples, but only "p" does.
There are variations on how to ideally meet the desired criteria. This variant was chosen to demonstrate how a minimal, universal @context combined allows the prefix:suffix to pull a lot of weight, to a point where addition of new doc primitives can be done without touching already deployed @context code in the wild.
2. RDF serialization of 'freeform' named, ordered sequences
Consider an object model with named, unordered, many-to-'any' mappings called 'Properties' and named, ordered many-to-many mappings called 'Relations', where the namespaces of Properties and Relations are disjoint. The names of these mappings are mutable, ad hoc, even application private in nature, so they can't be expected to have ontology definitions. Nevertheless the object model has a need for universal serialization which allows reasoning: a JSON serialization format with RDF correspondence makes sense.
A reasonable JSON serialization of such an object might be:
{
"stringValue": "http://this.uri.is.not.an/object.reference",
"toThing": { "@id": "http://some.thing/#this.is.an.object.reference" },
"Relation:ROOMS": ["http://some.thing/room#3", "http://some.thing/room#4"],
"Relation:SENSORS": ["http://some.thing/sensor#1", "http://some.thing/sensor#2"]
}
Similar to case 1, a generic context
{
"@context": {
"@vocab": "http://example.org/Property/",
"Relation": {
"@id": "http://example.org/Relation/",
"@type": "@id",
"@container": "@list",
"@prefix": true
}
}
}
would be 'future proof' and allow emitting reasonable and relatively simple RDF triple graphs. Here the need is to have prefix support for "@type": "@id" as well in addition to "@container": "@list", as per the proposal.
Metadata
Metadata
Assignees
Type
Projects
Status