-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should @id
of parent objects be used as a base IRI for relative IRI references?
#447
Comments
Actually, I think that the in-scope Regarding cascading objects and relative IRIs, IMO, this would be too sophisticated for the JSON-LD processing model, and has no basis in RFC3986 URI resolution. |
The same JSON-LD document can be represented in different forms, meaning we could reverse the roles of the parent object and the nested object and keep the document's meaning (i.e., its graph form) the same. Introducing such a convention would make such manipulations more difficult. Explicit is better than implicit ⇒ Perhaps this rule would be too implicit IMHO. |
I think that makes sense:
The part that I am still confused about is with embedding, this implies that you should inject a Meaning that if you dereference {
"@id": "https://thing1.example",
"https://relation1.example": {
"@id": "https://thing2.example",
"https://relation2.example": {
"@id": "#relative" // thing1.example/#relative
}
}
} then {
"@id": "https://thing2.example",
"https://relation2.example": {
"@id": "#relative" // thing2.example/#relative
}
} then {
"@id": "https://thing1.example",
"https://relation1.example": {
"@id": "https://thing2.example" // this will be fetched and embedded later
}
} then it is not enough to simply replace id-references with the document as-is. You would need to formulate a document like so: {
"@id": "https://thing1.example",
"https://relation1.example": {
"@context": { // we inject this to fix the relative reference
"@base": "https://thing2.example/" // note the trailing slash
},
"@id": "https://thing2.example",
"https://relation2.example": {
"@id": "#relative" // fixed, it is now thing2.example/#relative
}
}
} This is a pitfall when it comes to relative references and hydration / embedding. I guess it applies to JSON-LD Best Practices? "To preserve semantics, when fetching a document over the network that contains relative references, you should inject a base IRI declaration before embedding that representation?" |
You could achieve the nested-base using property- or type-scoped contexts, but that would be obscure and error prone. The fact is, that RFC3986 is pretty clear on how to expand relative URIs by finding an appropriate base. The base URI can be default, the document location, the Base URI of an encapsulating entity, of a Base URI embedded in the content (i.e., There is no precedent for having the URI of an entity becoming the base for nested relative URIs. |
By my understanding, the way to absolutize a relative IRI reference in JSON-LD is currently something like this:
JsonLdProcessor
hasJsonLdOptions.base
set, then use that.@base
declaration, then use that.<base>
can be used?However, there is a possibility for objects to be nested or embedded in other objects. Especially in non-flattened form.
I would interpret a document like so:
where it seems like the node with
"id": "#atproto_pds"
is part of its parent context, the node with"id": "did:plc:ewvi7nxzyoun6zhxrhs64oiz"
... which I think represents the document?So the question is: Should the
@id
of parent objects be considered in the expansion of relative IRI references? If not, why not? If yes, should we consider only the top-level parent or should we instead consider the most recent absolutized parent?The text was updated successfully, but these errors were encountered: