Description
There are a number of different issues regarding the need to define content for a term which is expanded in node values of that term, creating term-specific contexts, or supporting scoped contexts for framing. I think that all of these may be satisfied by specifying default content which is added to the node values of that term.
-
247 Scoped Contexts – This feature seeks to allow
@context
to be used within a term definition, which would allow for additional term definitions to come into affect for values of that term. -
262 JSON key specific default namespaces for values – This proposal seeks to allow the definition of
@vocab
within a term definition, which would change the way simple keys and types are resolved for values of that term. (Clearly, this could be implemented using Scoped contexts #247). -
315 Framing should use embedded contexts for compaction – This proposal suggested allowing a frame to use different
@context
at different levels, which would be preserved in the framed document. If Scoped contexts #247 were supported, this would have the same effect. -
369 Term-level
@base/@vocab
– Pretty much the same as Feature proposal: JSON key specific default namespaces for values #262 and could be implemented by Scoped contexts #247. -
415 Scoping context based on the
@type
– describes scoping contexts based on@type
. This is similar to Scoped contexts #247, but rather than basing it on node values of a term, it is automatically applied to node definitions having a specific@type
. It's not clear what existing mechanism this might hook off of, and IMHO, this is better supported via Scoped contexts #247 (or similar). - We've also seen a general mis-understanding of how
@context
works, with the supposed capability to generate triples based on things in the@context
(see Possible to generate implied triples from@context
?, for one).
It strikes me that these could all be supported by a single mechanism to add default content to a node values of a term. Consider, for example:
{
"@context": {
"schema": "http://schema.org/",
"foaf": "http://xmlns.com/foaf/0.1/",
"bibo": "http://purl.org/ontology/bibo/",
"@vocab": "schema",
"author": {
"@id": "schema:author",
"@type": "@id",
"@content": {
"@context": {
"@vocab": "foaf",
"homepage": {"@id": "foaf:homepage", "@type": "@id"}
},
"@type": ["foaf:Person", "schema:Person"]
}
}
},
"@id": "http://www.w3.org/TR/json-ld/",
"@type": "bibo:Document",
"author": {
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}
}
The expansion rules for node values of term having @content
would be to merge the value of @content
into those definitions, meaning that keys and/or values are added as necessary, so that further expansion of that node definition would include those values. Note that as @context
is part of @content
, this would add that context to the node definition. This would effectively be equivalent to the following:
{
"@context": {
"schema": "http://schema.org/",
"foaf": "http://xmlns.com/foaf/0.1/",
"bibo": "http://purl.org/ontology/bibo/",
"@vocab": "schema",
"author": {
"@id": "schema:author",
"@type": "@id"
}
},
"@id": "http://www.w3.org/TR/json-ld/",
"@type": "bibo:Document",
"author": {
"@context": {
"@vocab": "foaf",
"homepage": {"@id": "foaf:homepage", "@type": "@id"}
},
"@type": ["foaf:Person", "schema:Person"]
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}
}
When compacting, term selection would consider node definitions having the (non-@context
) content from @content
as part of the matching criteria. (Note, this would need to place some limitations on nested node definitions).
This mechanism solves all of the above scenarios, and I believe is tractable without excessive complication in either compaction or expansion. It also addresses the framing issues where having different contexts be in effect for different parts of the frame.
If generally acceptable, this could be added to a forthcoming CG release of the specifications.