Interpretation as RDF
1. Export vs Interpretation
|
The JSON document can be exported as RDF. This resembles simply mapping the JSON tree document to a corresponding tree (RDF graph) of RDF resources. However, to actually export the knowledge encoded in a Connected JSON graph, is often more interesting. This specification does not define an RDF Export, just an RDF Interpretation. |
2. Namespace Map (@context)
The document-level @context is used to expand prefixed IDs into full URIs for RDF export.
See Context (Namespace Map) for details on how IDs are expanded.
If no @context is provided, a default @vocab may be supplied at export time by the environment as a parameter. If no @vocab is given by any means, it defaults to the local file path using the file:// scheme, with URL-encoding, where required.
3. Node URI
Each node id is expanded to a URI using the @context namespace map (see ID Expansion).
Similarly, each edge id is expanded to a URI.
If the resulting URI would be syntactically invalid (e.g. because the id contains characters not allowed in a URI), the invalid characters must be percent-encoded.
Ports are ignored in RDF.
4. Edge Types
The type of an edge can be stated at the edge level and/or at the endpoint level. For bi-edges the edge level works fine and has a clear interpretation, even as RDF. However, an n-ary edge cannot always be interpreted as RDF. I.e., the hyper-edge itself is not mapped to triples, but the induced bi-edges are.
The edge type (edge.type) defines a type for each endpoint. It can be overwritten per endpoint (endpoint.type).
At export time, the type string (a node id) is expanded to a URI using the @context namespace map.
-
Compute the effective endpoint type:
-
Start with the edge-level
type. -
If the endpoint defines its own
type, it overrides the edge-level type. -
Expand the effective type to a URI using
@context.
-
-
Process each pair of endpoints (A,B):
-
Sort pair into first and second.
-
For each type URI in the pair, generate an RDF triple from
intoout:If in has a type URI, generate
(in.node, in.typeUri, out.node).If out has a type URI, generate
(in.node, out.typeUri, out.node).
-
Input |
Resulting RDF Order |
||
|---|---|---|---|
A |
B |
Subject |
Object |
|
|
Skip |
|
|
|
A |
B |
|
|
A |
B |
|
|
B |
A |
|
|
Skip |
|
|
|
B |
A |
|
|
B |
A |
|
|
A |
B |
|
|
A |
B |
5. Examples
5.1. Simple Bi-Edge
Given document @context: { "ex": "https://example.org/" }
{
"endpoints": [
{ "node": "n12",
"direction": "in" },
{ "node": "n17",
"direction": "out",
"type": "ex:worksAt" }
]
}
interpretation as RDF (Turtle Syntax)
@prefix ex: <https://example.org/> .
ex:n12 ex:worksAt ex:n17 .
The following Extended CJ (→GEF) example uses source/target and endpoints, which is allowed but uncommon. The endpoints stated using source/target have no endpoint types defined.
|
5.2. Hyper-Edge
Given document @context: { "ex": "https://example.org/" }
{
"id": "sale123",
"source": ["n12","n3","n123"],
"target": ["n17","n100"],
"endpoints": [
{ "node": "n100", "direction": "in",
"type": "ex:sells" },
{ "node": "n12", "direction": "in",
"type": "ex:buys" },
{ "node": "n3", "direction": "undir" },
{ "node": "item-1", "direction": "out" }
]
}
interpretation as RDF (Turtle Syntax)
@prefix ex: <https://example.org/> .
ex:n100 ex:sells ex:item-1 .
ex:n12 ex:buys ex:item-1 .