Skip to content

More context processing #377

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

Merged
merged 11 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 37 additions & 27 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ <h2>RDF Serialization/Deserialization</h2>
<ul>
<li>the active <a>term definitions</a> which specify how
keys and values have to be interpreted (<a>array</a> of <a>term definitions</a>),</li>
<li>the current <a>base IRI</a> (<a>IRI</a>),</li>
<li>the current <dfn data-lt="context-base-iri" data-lt-noDefault>base IRI</dfn> (<a>IRI</a>),</li>
<li class="changed">the <dfn>original base URL</dfn> (<a>IRI</a>),</li>
<li>an optional <a>vocabulary mapping</a> (<a>IRI</a>),</li>
<li>an optional <a>default language</a> (<a>string</a>),</li>
Expand Down Expand Up @@ -1131,7 +1131,7 @@ <h3>Overview</h3>
<p>If <a>context</a> is a <a class="changed">map</a>,
it is a <a data-cite="JSON-LD11#dfn-context-definition">context definition</a>.
We first update
the <a>base IRI</a>,
the <a class="changed" data-lt="context-base-iri">base IRI</a>,
<span class="changed">the <a>default base direction</a></span>,
the <a>default language</a>,
<span class="changed">context propagation</span>,
Expand Down Expand Up @@ -1159,10 +1159,11 @@ <h3>Overview</h3>
When an <a>active context</a> is initialized, the value
of the <a>original base URL</a>
is initialized from the original {{RemoteDocument/documentUrl}}
of the document containing the initial <a>context</a>.
of the document containing the initial <a>context</a>, if available,
otherwise from the {{JsonLdOptions/base}} API option.
This is necessary when resetting the <a>active context</a>
by setting it to `null`
to retain the original default <a>base IRI</a>.</p>
to retain the original default <a class="changed" data-lt="context-base-iri">base IRI</a>.</p>

<p>Then, for every other <a>entry</a> in <a>local context</a>, we update
the <a>term definition</a> in <var>result</var>. Since
Expand Down Expand Up @@ -1223,20 +1224,25 @@ <h3>Algorithm</h3>
has been detected and processing is aborted.</li>
<li>Initialize <var>result</var> as a
newly-initialized <a>active context</a>,
<span class="changed">setting <a>previous context</a> in <var>result</var>
to the previous value of <var>result</var> if <var>propagate</var> is <code>false</code>
and both <a>base IRI</a> and <a>original base URL</a> to the value of
<a>original base URL</a> in <var>active context</var></span>.</li>
<span class="changed">
setting both <a data-lt="context-base-iri">base IRI</a> and <a>original base URL</a> to the value of
<a>original base URL</a> in <var>active context</var></span>,
and, if <var>propagate</var> is <code>false</code>,
<a>previous context</a> in <var>result</var>
to the previous value of <var>result</var>.</li>
<li>Continue with the next <var>context</var>.</li>
</ol>
</li>
<li id="alg-context-string">If <var>context</var> is a <a>string</a>,
<ol>
<li>Initialize <var>context</var> to the result of resolving <var>context</var> against
<var>base URL</var>.
<var>base URL</var>. If <var>base URL</var> is not a valid <a>IRI</a>,
then <var>context</var> MUST be a valid <a>IRI</a>, otherwise
a <a data-link-for="JsonLdErrorCode">loading document failed</a> error
has been detected and processing is aborted.
<div class="note">
<var>base URL</var> is often not the same as {{JsonLdOptions/base}}
or the <a>base IRI</a> of the <var>active context</var>.
or the <a class="changed" data-lt="context-base-iri">base IRI</a> of the <var>active context</var>.
</div>
</li>
<li>If the number of entries in the <var>remote contexts</var> array
Expand All @@ -1247,7 +1253,10 @@ <h3>Algorithm</h3>
<li class="changed">If <var>context</var> was previously dereferenced,
then the processor MUST NOT do a further dereference, and
<a>context</a> is set to the
previously established <a>internal representation</a>.
previously established <a>internal representation</a>:
set <var>context document</var> to the previously dereferenced document,
and set <var>loaded context</var> to the value of the `@context`
<a>entry</a> from the document in <var>context document</var>.
<div class="note">Only the `@context` <a>entry</a> need be retained.</div>
</li>
<li class="changed">Otherwise, set <var>context document</var>
Expand Down Expand Up @@ -1350,13 +1359,13 @@ <h3>Algorithm</h3>
<li>Initialize <var>value</var> to the value associated with the
<code>@base</code> <a>entry</a>.</li>
<li>If <var>value</var> is <code>null</code>, remove the
<a>base IRI</a> of <var>result</var>.</li>
<a class="changed" data-lt="context-base-iri">base IRI</a> of <var>result</var>.</li>
<li>Otherwise, if <var>value</var> is an <a>IRI</a>,
the <a>base IRI</a> of <var>result</var> is set to <var>value</var>.</li>
the <a class="changed" data-lt="context-base-iri">base IRI</a> of <var>result</var> is set to <var>value</var>.</li>
<li>Otherwise, if <var>value</var> is a <a>relative IRI reference</a> and
the <a>base IRI</a> of <var>result</var> is not <code>null</code>,
set the <a>base IRI</a> of <var>result</var> to the result of
resolving <var>value</var> against the current <a>base IRI</a>
the <a class="changed" data-lt="context-base-iri">base IRI</a> of <var>result</var> is not <code>null</code>,
set the <a class="changed" data-lt="context-base-iri">base IRI</a> of <var>result</var> to the result of
resolving <var>value</var> against the current <a class="changed" data-lt="context-base-iri">base IRI</a>
of <var>result</var>.</li>
<li>Otherwise, an
<a data-link-for="JsonLdErrorCode">invalid base IRI</a>
Expand Down Expand Up @@ -1508,7 +1517,7 @@ <h3>Algorithm</h3>
a <var>term</var>,
and a map <var>defined</var>.
<span class="changed">The optional inputs are
<var>base URL</var>,
<var>base URL</var> defaulting to <code>null</code>,
<var>protected</var> which defaults to <code>false</code>,
and <var>override protected</var>, defaulting to <code>false</code>,
which is used to allow changes to protected terms.</span>.
Expand Down Expand Up @@ -3206,7 +3215,7 @@ <h3>Algorithm</h3>
with <var>value</var>.</li>
<li>Otherwise, if <var>document relative</var> is <code>true</code>
set <var>value</var> to the result of resolving <var>value</var> against
the <a>base IRI</a> from <var>active context</var>. Only the basic algorithm in
the <a class="changed" data-lt="context-base-iri">base IRI</a> from <var>active context</var>. Only the basic algorithm in
<a data-cite="RFC3986#section-5.2">section 5.2</a>
of [[RFC3986]] is used; neither
<a data-cite="RFC3986#section-6.2.2">Syntax-Based Normalization</a> nor
Expand Down Expand Up @@ -4178,7 +4187,7 @@ <h3>Algorithm</h3>
and processing is aborted.</li>
<li>If <var>vocab</var> is <code>false</code>,
transform <var>var</var> to a <a>relative IRI reference</a> using
the <span class="changed"><a>base IRI</a> from <var>active context</var>, if it exists</span>.</li>
the <span class="changed"><a data-lt="context-base-iri">base IRI</a> from <var>active context</var>, if it exists</span>.</li>
<li>Finally, return <var>var</var> as is.</li>
</ol>
</section>
Expand Down Expand Up @@ -5741,16 +5750,16 @@ <h3>Algorithm</h3>
If {{RemoteDocument/document}} cannot be transformed to the <a>internal representation</a>,
reject <var>promise</var> passing a <a data-link-for="JsonLdErrorCode">loading document failed</a> error.</li>
<li>Initialize a new empty <var>active context</var>.
The <a>base IRI</a> and <a>original base URL</a> of the <var>active context</var> is set to the {{RemoteDocument/documentUrl}}
The <a data-lt="context-base-iri">base IRI</a> and <a>original base URL</a> of the <var>active context</var> is set to the {{RemoteDocument/documentUrl}}
from <var>remote document</var>, if available;
otherwise to <code>null</code>.
If set, the {{JsonLdOptions/base}} option from <a data-lt="jsonldprocessor-expand-options">options</a> overrides the <a>base IRI</a>.</li>
otherwise to the {{JsonLdOptions/base}} option from <a data-lt="jsonldprocessor-expand-options">options</a>.
If set, the {{JsonLdOptions/base}} option from <a data-lt="jsonldprocessor-expand-options">options</a> overrides the <a data-lt="context-base-iri">base IRI</a>.</li>
<li>If the {{JsonLdOptions/expandContext}} option in <a data-lt="jsonldprocessor-expand-options">options</a> is set,
update the <var>active context</var> using the <a href="#context-processing-algorithm">Context Processing algorithm</a>,
passing the {{JsonLdOptions/expandContext}} as <var>local context</var>
and {{JsonLdOptions/expandContext}} as <var>base URL</var>.
and the <a>original base URL</a> from <var>active context</var> as <var>base URL</var>.
If {{JsonLdOptions/expandContext}} is a <a class="changed">map</a> having an <code>@context</code> <a>entry</a>,
pass that <a data-lt="entry">entry's</a> value instead.</li>
pass that <a data-lt="entry">entry's</a> value instead for <var>local context</var>.</li>
<li>If <var>remote document</var> has a {{RemoteDocument/contextUrl}},
update the <var>active context</var> using the <a href="#context-processing-algorithm">Context Processing algorithm</a>,
passing the {{RemoteDocument/contextUrl}} as <var>local context</var>,
Expand All @@ -5759,8 +5768,9 @@ <h3>Algorithm</h3>
passing the <var>active context</var>,
{{RemoteDocument/document}} from <var>remote document</var> or <a data-lt="jsonldprocessor-expand-input">input</a>
if there is no <var>remote document</var> as <var>element</var>,
{{RemoteDocument/documentUrl}} as <var>base URL</var>,
and <span class="changed">{{JsonLdOptions/frameExpansion}}</span>
`null` as <var>active property</var>,
{{RemoteDocument/documentUrl}} as <var>base URL</var>, if available, otherwise to {{JsonLdOptions/base}},
and the <span class="changed">{{JsonLdOptions/frameExpansion}}</span>
and <span class="changed">and {{JsonLdOptions/ordered}}</span>
flags from <a data-lt="jsonldprocessor-compact-options">options</a>.
<ol id="api-expand-post-processing" class="changed">
Expand Down Expand Up @@ -6092,7 +6102,7 @@ <h3>Algorithm</h3>

<pre class="idl">
dictionary JsonLdOptions {
USVString? base;
USVString? base = null;
boolean compactArrays = true;
boolean compactToRelative = true;
LoadDocumentCallback? documentLoader = null;
Expand Down
6 changes: 6 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Tests driven from a top-level [manifest](manifest.jsonld) and are defined into [
* [expand](expand-manifest.jsonld) tests have _input_ and _expected_ documents.
The _expected_ results can be compared using [JSON-LD object comparison](#json-ld-object-comparison) with the processor output.

Expansion tests may have a `expandContext` option, which is treated
as an IRI relative to the manifest.

For *NegativeEvaluationTests*, the result is a string associated with the expected error code.
* [html](html.jsonld) tests have _input_ and _expected_ documents and an optional _context_ document.
The _expected_ results can be compared using [JSON-LD object comparison](#json-ld-object-comparison) with the processor output
Expand Down Expand Up @@ -46,6 +49,9 @@ Tests driven from a top-level [manifest](manifest.jsonld) and are defined into [
* [toRdf](toRdf-manifest.jsonld) tests have _input_ and _expected_ documents.
The _expected_ results can be compared using [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism).

ToRdf tests may have a `expandContext` option, which is treated
as an IRI relative to the manifest.

Unless `processingMode` is set explicitly in a test entry, `processingMode` is compatible with both `json-ld-1.0` and `json-ld-1.1`.

Test results that include a context input presume that the context is provided locally, and not from the referenced location, thus the results will include the content of the context file, rather than a reference.
Expand Down
2 changes: 1 addition & 1 deletion tests/context.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"compactArrays": { "@type": "xsd:boolean" },
"compactToRelative": { "@type": "xsd:boolean" },
"contentType": { "@type": "xsd:boolean" },
"expandContext": { "@type": "xsd:string" },
"expandContext": { "@type": "@id" },
"httpLink": { "@type": "xsd:string", "@container": "@set" },
"httpStatus": { "@type": "xsd:integer" },
"processingMode": { "@type": "xsd:string" },
Expand Down
3 changes: 3 additions & 0 deletions tests/expand-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ <h3><a href="expand-manifest.jsonld">expand</a> tests have <em>input</em> and <e

<p>The <em>expected</em> results can be compared using <a href="#json-ld-object-comparison">JSON-LD object comparison</a> with the processor output.</p>

<p>Expansion tests may have a <code>expandContext</code> option, which is treated
as an IRI relative to the manifest.</p>

<p>For <em>NegativeEvaluationTests</em>, the result is a string associated with the expected error code.</p>
<p>Unless <code>processingMode</code> is set explicitly in a test entry, <code>processingMode</code> is compatible with both <code>json-ld-1.0</code> and <code>json-ld-1.1</code>.</p>

Expand Down
2 changes: 1 addition & 1 deletion tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@
"name": "expandContext option",
"purpose": "Use of the expandContext option to expand the input document",
"option": {
"expandContext": "0077-context.jsonld"
"expandContext": "expand/0077-context.jsonld"
},
"input": "expand/0077-in.jsonld",
"expect": "expand/0077-out.jsonld"
Expand Down
3 changes: 3 additions & 0 deletions tests/html-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ <h3><a href="expand-manifest.jsonld">expand</a> tests have <em>input</em> and <e

<p>The <em>expected</em> results can be compared using <a href="#json-ld-object-comparison">JSON-LD object comparison</a> with the processor output.</p>

<p>Expansion tests may have a <code>expandContext</code> option, which is treated
as an IRI relative to the manifest.</p>

<p>For <em>NegativeEvaluationTests</em>, the result is a string associated with the expected error code.</p>
<h3><a href="html.jsonld">html</a> tests have <em>input</em> and <em>expected</em> documents and an optional <em>context</em> document.</h3>

Expand Down
6 changes: 6 additions & 0 deletions tests/manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ <h3><a href="expand-manifest.jsonld">expand</a> tests have <em>input</em> and <e

<p>The <em>expected</em> results can be compared using <a href="#json-ld-object-comparison">JSON-LD object comparison</a> with the processor output.</p>

<p>Expansion tests may have a <code>expandContext</code> option, which is treated
as an IRI relative to the manifest.</p>

<p>For <em>NegativeEvaluationTests</em>, the result is a string associated with the expected error code.</p>
<h3><a href="html.jsonld">html</a> tests have <em>input</em> and <em>expected</em> documents and an optional <em>context</em> document.</h3>

Expand Down Expand Up @@ -70,6 +73,9 @@ <h3><a href="toRdf-manifest.jsonld">toRdf</a> tests have <em>input</em> and <em>
<p>Some tests require the use of <a href="https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-05">JSON Canonicalization Scheme</a> to properly generate RDF Literals from JSON literal values. This algorithm is non-normative, but is assumed to be used to properly compare results. These tests are marked using the <code>useJCS</code> option.</p>

<p>The <em>expected</em> results can be compared using <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism">RDF Dataset Isomorphism</a>.</p>

<p>ToRdf tests may have a <code>expandContext</code> option, which is treated
as an IRI relative to the manifest.</p>
<p>Unless <code>processingMode</code> is set explicitly in a test entry, <code>processingMode</code> is compatible with both <code>json-ld-1.0</code> and <code>json-ld-1.1</code>.</p>

<p>Test results that include a context input presume that the context is provided locally, and not from the referenced location, thus the results will include the content of the context file, rather than a reference.</p>
Expand Down
3 changes: 3 additions & 0 deletions tests/remote-doc-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ <h3><a href="expand-manifest.jsonld">expand</a> tests have <em>input</em> and <e

<p>The <em>expected</em> results can be compared using <a href="#json-ld-object-comparison">JSON-LD object comparison</a> with the processor output.</p>

<p>Expansion tests may have a <code>expandContext</code> option, which is treated
as an IRI relative to the manifest.</p>

<p>For <em>NegativeEvaluationTests</em>, the result is a string associated with the expected error code.</p>
<h3><a href="remote-doc-manifest.jsonld">remote-doc</a> tests have <em>input</em> and <em>expected</em> documents.</h3>

Expand Down
6 changes: 6 additions & 0 deletions tests/template.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

The _expected_ results can be compared using [JSON-LD object comparison](#json-ld-object-comparison) with the processor output.

Expansion tests may have a `expandContext` option, which is treated
as an IRI relative to the manifest.

For *NegativeEvaluationTests*, the result is a string associated with the expected error code.

- if manifest['sequence'].first.is_a?(String) || manifest['sequence'].any? {|te| te['@type'].include?('jld:HtmlTest')}
Expand Down Expand Up @@ -89,6 +92,9 @@

The _expected_ results can be compared using [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism).

ToRdf tests may have a `expandContext` option, which is treated
as an IRI relative to the manifest.

:markdown
Unless `processingMode` is set explicitly in a test entry, `processingMode` is compatible with both `json-ld-1.0` and `json-ld-1.1`.

Expand Down
2 changes: 1 addition & 1 deletion tests/toRdf-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@
"name": "expandContext option",
"purpose": "Use of the expandContext option to expand the input document",
"option": {
"expandContext": "e077-context.jsonld"
"expandContext": "toRdf/e077-context.jsonld"
},
"input": "toRdf/e077-in.jsonld",
"expect": "toRdf/e077-out.nq"
Expand Down