-
Notifications
You must be signed in to change notification settings - Fork 35
Add support for the alternate
link relation
#133
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
Conversation
…ld+json` to be used as a redirect if the retrieved document is not JSON. For w3c/json-ld-syntax#204.
Note that I wrote this so that the |
@@ -6372,6 +6379,9 @@ <h2>Changes since JSON-LD Community Group Final Report</h2> | |||
a context. When this is set, vocabulary-relative IRIs, such as the | |||
<a>entries</a> of <a>node objects</a>, are expanded or compacted relative | |||
to the <a>base IRI</a> and the <a>vocabulary mapping</a> using string concatenation.</li> | |||
<li>In the <a>LoadDocumentCallback</a>, if the retrieved content is not `application/ld+json` | |||
and there is a link header with `rel=alternate` and `type=application/ld+json`, redirect | |||
to that content.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to be discussed (it is not just editorial).
This would create a different behaviour when the document is accessed directly, than when it is accessed through the "link header indirection". So I am not a big fan of the idea.
I would rather encourage the author of the JSON-LD document to explicitly set the base to the URL o the non-JSON-LD document, if that is the behaviour they intend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is definitely prospective, as the issue is still marked to be discussed, but I wanted to get it out there and see the consequences. The link header shouldn’t affect any json format, but would affect html content. What document base should be applied can be debated, but using the original document has precedent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think I disagree with @pchampin ... and that we want to treat this like we do with redirects, which I believe uses the original document. The argument for doing what @pchampin suggests would be that there's no way to know ahead of time what the final document will be, so you couldn't set the base to it, whereas you could set the base to the original document if you wanted it to stick.
But, processors could have a flag to switch to this other behavior. It seems to me that the sensible default would be the original document. Especially given the way that we expect this feature to be used ... which is that the linked document is really a hidden implementation detail. If you wanted to use the linked document directly you would have specified it instead of some, e.g., HTML document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 to introducing another flag, though. If the document should have some specific base different from the originally referenced resource, it can use @base
.
My thought in using the original resource base, rather than the referenced document, is essentially the same reasoning that lead to the semantics of HTTP status 303 for range-14 considerations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this use of alternate
(which comes from HTML primarily) is meant to supplant using content negotiation, then the expectation would be (afaict) that the original resource URL would (semantically) be the correct base URL--which I think agrees with what @gkellogg said above.
Once the alternate
is retrieved it should experientially be like getting a content negotiated response with a Content-Location
set to the alternate
and having Location
still be set to the original Request-URI--which is how content negotiation plays out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mentioned on the call Friday was that the only definition of rel="alternate"
(that I'm aware of) is in https://html.spec.whatwg.org/multipage/links.html#rel-alternate
The summary definition is "Gives alternate representations of the current document." but the follow-on expansion on it includes "The meaning of this keyword depends on the values of the other attributes."
The examples in that section include alternate CSS styles (i.e. rel="alternate stylesheet"
), Atom/RSS alternate representations (i.e. rel="alternate" type=""
), and using it for language [content] negotiation (i.e. rel="alternate" hreflang=""
+/- type=""
).
So, using alternate
here to accomplish a pre-flight content negotiation (of sorts) is not without its precedence conceptually. However, none of that directly answers the base URI situation...as in the closest experiential case (language negotiation) the browser would navigate to the new resource based on language preferences--thereby acting more like a 30*
redirect than like content negotiation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, if we stick with alternate
, we may need to require other link parameters (or type parameters) to clarify that this is a representation of the current document as a context vs. a representation of the current document expressed in JSON-LD (i.e. as a data document).
We could use the existing context profile URL (which is used as a rel
in Interpreting JSON as JSON-LD). The experience would be similar to referencing a data document as the context of another data document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the parallel with HTTPRange-14 . But I see nowhere in those documents an indication that relative IRIs in the target document should be resolved against the source document's IRI...
There's a discussion in Cool URIs:
... Each of the RDF documents would contain statements about the appropriate resource, using the original URI, e.g. http://www.example.com/id/alice, to identify the described resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but they do not say that a relative URI could or should be used for that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, I think you need to raise a new issue for discussion, because we seem to have quite different views on this, and discussing in a merged PR isn't a good way to be sure we resolve it.
We resolved to use the 303 redirect semantics.
In fact, this is not simply for contexts, but for any non-JSON content where we want to use a JSON-LD representation. I didn’t think that anything other than the |
Gotcha, so if I shipped a data document describing |
A context is just JSON-LD including The document loader will follow a link, if the retrieved resource is not JSON, for any of these cases. The use for context retrieval is incidental. |
… with type
application/ld+json
to be used as a redirect if the retrieved document is not JSON.For w3c/json-ld-syntax#204.
Preview | Diff