-
Notifications
You must be signed in to change notification settings - Fork 35
Rewrite LoadDocumentCallback #87
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
Per our meeting, I've updated the document loader section to consolidate HTML and profile processing. I'll give this until EOD Monday before pulling and releasing a new WD, pending feedback. As discussed today, we won't close this issue pending further review, but don't want to hold back a WD. |
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.
Organizationally, this is a massive improvement, IMO -- a much better separation of concerns. Thanks, @gkellogg! I will only be able to offer more detailed feedback (if any) when we attempt implementation. There do seem to be more profile requirements than before (from the last time I reviewed) and I don't know what impact there will be on existing systems (hopefully none!).
The profile requirement is that systems that don't process HTML, which includes all 1.0 processors, as they will reject the mime type, should raise the same error they would have under 1.0. 1.1 full processors MUST handle the HTML content, and include The net is that to be a full processor you'll need to support HTML and a callback implementation must conform to the specified behavior. We do have tests to make sure that it handles the requests properly, but not for processor type, nor do we presently have a way to test the compliance of custom loaders, but I'm not sure how we would. There is some cleanup of the test needed to separate out the HTML behavior into a different manifest. |
…e-specific processing, and use in *expand* and *Context Processing*.
Committed @dlongley's suggestions. Co-Authored-By: gkellogg <[email protected]>
bb0d61a
to
fb1e0ce
Compare
index.html
Outdated
</li> | ||
</ol> | ||
</li> | ||
<li>Otherwise, if the retrieved document's <a>Content-Type</a> is neither |
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.
Same remark as above, this is an "else", not an "else if".
Suggested change (1/3)
<li>Otherwise, if the retrieved document's <a>Content-Type</a> is neither | |
<li>Otherwise, the retrieved document's <a>Content-Type</a> is neither | |
<code>text/html</code>, |
index.html
Outdated
@@ -6014,6 +6084,8 @@ <h2>Changes since JSON-LD Community Group Final Report</h2> | |||
of type <code>application/ld+json;profile=http://www.w3.org/ns/json-ld#context</code>, | |||
or <code>application/ld+json</code> is used as the context for further processing. | |||
This allows a mechanism for documenting the content of a context using HTML.</li> | |||
<li>Consolodate <a>RemoteDocument</a> processing into the <a>LoadDocumentCallback</a> |
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.
<li>Consolodate <a>RemoteDocument</a> processing into the <a>LoadDocumentCallback</a> | |
<li>Consolidate <a>RemoteDocument</a> processing into the <a>LoadDocumentCallback</a> |
index.html
Outdated
</li> | ||
<li class="changed">If necessary, transform <a data-link-for="RemoteDocument">document</a> |
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 necessary" is not very clear to me. I'm guessing it means "if 'document' is a neither a dictionary not an array". This should be made explicit, all the more than a plain string is listed as a valid "internal representation" (which makes sense as the JSON syntax is able to represent a single string).
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'll change, but even though a string is a valid JSON document, it's not a valid JSON-LD document, so the intention should be clear.
index.html
Outdated
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <a data-link-for="JsonLdErrorCode">multiple context link headers</a> | ||
and processing is terminated.</p> | ||
<p>Processors MAY transform <var>document</var> to the <a>internal representation</a> | ||
using the <a href="#extract-script-content">Extract Script Content algorithm</a>.</p> |
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 is confusing: this algorithm is explicitly provided for processing HTML scripts, which is not what we have here. Furthermore, it may raise an 'invalid script element' error, which would be inappropriate here.
I suggest rephrasing this in the spirit of line 5116 (modulo the improvement that I suggested).
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'll just remove the bit about the Extract Script Content, as we don't really need to show how it should be transformed.
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, it's just the HTTP body, so it will always be in a string form. The contract allows an user-supplied implementation to do the transformation.
index.html
Outdated
<li>Otherwise, if <var>source</var> is undefined and the <a data-link-for="LoadDocumentOptions">extractAllScripts</a> option is not present, or <code>false</code>, | ||
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <a data-link-for="JsonLdErrorCode">loading document failed</a> | ||
and processing is terminated.</li> | ||
<li>Otherwise, if <var>source</var> is undefined and the <a data-link-for="LoadDocumentOptions">extractAllScripts</a> option is <code>true</code>, |
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 I understand correctly, this "otherwise" is an "else", but it reads like an "else if", which might confuse the reader.
I suggest rephtrasing it (1/2)
<li>Otherwise, if <var>source</var> is undefined and the <a data-link-for="LoadDocumentOptions">extractAllScripts</a> option is <code>true</code>, | |
<li>Otherwise,<var>source</var> is undefined and the <a data-link-for="LoadDocumentOptions">extractAllScripts</a> option is <code>true</code>. |
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 added some deeper lists to clarify.
index.html
Outdated
<code>application/json</code>, | ||
<code>application/ld+json</code>, | ||
nor any other media type using a | ||
<code>+json</code> suffix as defined in [[RFC6839]], |
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.
(cont 2/3)
<code>+json</code> suffix as defined in [[RFC6839]], | |
<code>+json</code> suffix as defined in [[RFC6839]]. |
index.html
Outdated
<code>application/ld+json</code>, | ||
nor any other media type using a | ||
<code>+json</code> suffix as defined in [[RFC6839]], | ||
reject the <var>promise</var> passing a <a data-link-for="JsonLdErrorCode">loading document failed</a> error.</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.
(cont. 3/3)
reject the <var>promise</var> passing a <a data-link-for="JsonLdErrorCode">loading document failed</a> error.</li> | |
Reject the <var>promise</var> passing a <a data-link-for="JsonLdErrorCode">loading document failed</a> error.</li> |
index.html
Outdated
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <a data-link-for="JsonLdErrorCode">loading document failed</a> | ||
and processing is terminated.</li> | ||
<li>Otherwise, if <var>source</var> is undefined and the <a data-link-for="LoadDocumentOptions">extractAllScripts</a> option is <code>true</code>, | ||
set <var>document</var> to a new empty <a>array</a>. |
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.
(cont 2/2)
set <var>document</var> to a new empty <a>array</a>. | |
Set <var>document</var> to a new empty <a>array</a>. |
index.html
Outdated
or the located element is not a <a>JSON-LD script element</a>, | ||
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <a data-link-for="JsonLdErrorCode">loading document failed</a> | ||
and processing is terminated.</p></li> | ||
<li>If <var>source</var> is defined and the, |
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.
Something is missing between "and the" and the trailing comma.
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 should simply remove the "and the".
Thanks @pchampin, the algorithm had an odd branch logic because of some fall-through behavior. With some extra structure based on your suggestions, I think it reads more clearly. |
to include most HTML-specific and profile-specific processing, and use in expand and Context Processing.
For #85.
Preview | Diff