Are "rich" references possible via reference nodes or embedded node objects? #853
-
The project I'm working on (UNTP) has a need to reference external nodes while also including some summary or preview data with the reference so that the referenced node can be represented meaningfully even when it cannot be dereferenced at the time (or may not be dereferencable). From the spec I think I've understood that a reference node can contain only the Click here to expand the example details of where the spec says reference nodes can contain only an `@id` propertyFrom the JSON-LD 1.1 spec intro:
In the JSON-LD specific term definitions, we see that a node reference is defined as:
That is, a node reference has only a single key: the "@context": {
"knows": {
"@id": "http://schema.org/Person"
}
},
...
"knows": {
"@id": "https://example.com/people/Manu"
},
... which, through the extra type coercion of "@context": {
"knows": {
"@id": "http://schema.org/Person",
"@type": "@id",
}
},
...
"knows": "https://example.com/people/Manu",
... The Syntax Tokens and Keywords similarly identifies the
I understand this to mean that:
This dual function of the Yet, the section on embedding with its example 94 populates the {
"@context": {
"@vocab": "http://xmlns.com/foaf/0.1/"
},
"@type": "Person",
"name": "Manu Sporny",
"knows": {
"@id": "https://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg"
}
} This appears to be exactly what I thought the spec was saying shouldn't happen (a reference node with more than an Indeed the small overview section on Node Identifiers seems to imply that the {
"@context": {
...
"name": "http://schema.org/name"
},
"@id": "http://me.markus-lanthaler.com/",
"name": "Markus Lanthaler",
...
} I'm keen to understand whether that is totally fine (and why then the "reference node" sections talks about only having the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Not suggesting this is valid, but from a programming perspective I'd imagine something like the following that allows the reference link to still have just the one {
"@id": "some-unique-id-1",
"_cached_properties": {
"name": "Markus Lanthaler",
...
}
},
Importantly, this also emphasises that they are cached properties (ie. could have been updated since), rather than defining a new entity that includes the properties with the id as if they are a separate node). |
Beta Was this translation helpful? Give feedback.
-
Now I am answering my own question: Rich references appear to be handled fine - rather than defining new nodes, the data is merged together based on the unique Using the playground with the following json-ld: {
"@context": {
"@vocab": "http://xmlns.com/foaf/0.1/"
},
"@id": "http://manu.sporny.org/about#manu",
"@type": "Person",
"name": "Manu Sporny",
"knows": [{
"@id": "https://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg"
}, {
"@id": "http://manu.sporny.org/about#manu",
"name": "Manu Spornie",
"@type": "Person"
}]
} which happens to have the node with {
"@context": "http://schema.org/",
"@graph": [
{
"id": "http://manu.sporny.org/about#manu",
"type": "foaf:Person",
"foaf:knows": [
{
"id": "https://greggkellogg.net/foaf#me"
},
{
"id": "http://manu.sporny.org/about#manu"
}
],
"foaf:name": [
"Manu Spornie",
"Manu Sporny"
]
},
{
"id": "https://greggkellogg.net/foaf#me",
"type": "foaf:Person",
"foaf:name": "Gregg Kellogg"
}
]
} If I correct the typo on the name, then it just collapses to: {
"@context": "http://schema.org/",
"@graph": [
{
"id": "http://manu.sporny.org/about#manu",
"type": "foaf:Person",
"foaf:knows": [
{
"id": "https://greggkellogg.net/foaf#me"
},
{
"id": "http://manu.sporny.org/about#manu"
}
],
"foaf:name": "Manu Sporny"
},
{
"id": "https://greggkellogg.net/foaf#me",
"type": "foaf:Person",
"foaf:name": "Gregg Kellogg"
}
]
} This is perhaps more obvious if looking at the RDF triplets for the document. When including the typo, the RDF triplets (in table format) look like: But if I fix the typo, then the duplicated RDF triplet is removed (so there is only one entry for Manu's name). So there does not appear to be any issue defining reference nodes with more than the In fact, now that I know what to look for, i can see this explicitly defined in the spec under node objects:
|
Beta Was this translation helpful? Give feedback.
Now I am answering my own question: Rich references appear to be handled fine - rather than defining new nodes, the data is merged together based on the unique
@id
(ie. the RDF triplets have the same subject). More accurately, it's not a reference, but a separate node object for the same node (@id
), which may define the same (or new) properties which will be merged into the resulting node (see below for spec reference).Using the playground with the following json-ld: