Skip to content

Commit 3f8bb4b

Browse files
committed
Treat _inverse context_ as a field in the _active context_, which is initialized on demand. This simplifies algorithm calling sequences and better captures implementation experience while not making any behavioral change.
1 parent 360270d commit 3f8bb4b

File tree

2 files changed

+78
-45
lines changed

2 files changed

+78
-45
lines changed

common/algorithm-terms.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@
4646
Used as a macro within various algorithms as to reduce the language used to describe
4747
the process of compacting a <a>string</a> <var>var</var> representing an <a>IRI</a> or <a>keyword</a>
4848
using an <var>active context</var> either specified directly, or coming from the scope of
49-
the algorithm step using this term and <var>inverse context</var> also taken
50-
from the scope of the algorithm step using this term.
49+
the algorithm step using this term.
5150
An optional <var>value</var> is used, if explicitly provided.
52-
Unless specified,
53-
the <var>vocab</var> flag defaults to `true`,
51+
Unless specified, the <var>vocab</var> flag defaults to `true`,
5452
and the <var>reverse</var> flag defaults to `false`.
5553
<ol>
5654
<li>Return the result of using the <a data-cite="JSON-LD11-API#iri-compaction">IRI Compaction algorithm</a>,
57-
passing <var>active context</var>, <var>inverse context</var>,
55+
passing <var>active context</var>,
5856
<var>var</var>,
5957
<var>value</var> (if supplied),
6058
<var>vocab</var>,

index.html

Lines changed: 75 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,7 @@ <h2>RDF Serialization/Deserialization</h2>
10711071
keys and values have to be interpreted (<a>array</a> of <a>term definitions</a>),</li>
10721072
<li>the current <dfn data-lt="context-base-iri" data-lt-noDefault>base IRI</dfn> (<a>IRI</a>),</li>
10731073
<li class="changed">the <dfn>original base URL</dfn> (<a>IRI</a>),</li>
1074+
<li class="changed">an <dfn data-lt="context-inverse" data-lt-noDefault>inverse context</dfn> (<a>inverse context</a>),</li>
10741075
<li>an optional <a>vocabulary mapping</a> (<a>IRI</a>),</li>
10751076
<li>an optional <a>default language</a> (<a>string</a>),</li>
10761077
<li class="changed">an optional <a>default base direction</a> (`"ltr"` or `"rtl"`),</li>
@@ -1099,6 +1100,7 @@ <h2>RDF Serialization/Deserialization</h2>
10991100
in which case it is referred to as a <dfn>keyword alias</dfn>.</p>
11001101

11011102
<p>When processing, <var>active context</var> is initialized
1103+
<span class="changed">with a `null` <a data-lt="context-inverse">inverse context</a>,</span>
11021104
without any <a>term definitions</a>,
11031105
<a>vocabulary mapping</a>, <a class="changed">default base direction</a>, or <a>default language</a>.
11041106
If a <a>local context</a> is encountered during processing, a new
@@ -1165,6 +1167,12 @@ <h3>Overview</h3>
11651167
by setting it to `null`
11661168
to retain the original default <a class="changed" data-lt="context-base-iri">base IRI</a>.</p>
11671169

1170+
<p class="changed">When initialized, or when any entry of
1171+
an <a>active context</a> is changed,
1172+
or any associated <a>term definition</a> is added, changed, or removed,
1173+
the <a data-lt="context-inverse">inverse context</a> field
1174+
in <a>active context</a> is set to `null`.</p>
1175+
11681176
<p>Then, for every other <a>entry</a> in <a>local context</a>, we update
11691177
the <a>term definition</a> in <var>result</var>. Since
11701178
<a>term definitions</a> in a <a>local context</a>
@@ -1202,7 +1210,8 @@ <h3>Algorithm</h3>
12021210

12031211
<ol>
12041212
<li>Initialize <var>result</var> to the result of cloning
1205-
<var>active context</var>.</li>
1213+
<var>active context</var>,
1214+
<span class="changed">with <a data-lt="context-inverse">inverse context</a> set to `null`.</span>.</li>
12061215
<li class="changed">If <var>local context</var> is an object containing the member <code>@propagate</code>,
12071216
its value MUST be <a>boolean</a> <code>true</code> or <code>false</code>,
12081217
set <var>propagate</var> to that value.
@@ -2151,16 +2160,25 @@ <h3>Overview</h3>
21512160
<h3>Algorithm</h3>
21522161

21532162
<p>This algorithm has five required inputs. They are:
2154-
an <var>inverse context</var>, a <a>keyword</a> or <a>IRI</a>
2155-
<var>var</var>, an <a>array</a> <var>containers</var> that represents an
2163+
an <var class="changed">active context</var>,
2164+
a <a>keyword</a> or <a>IRI</a> <var>var</var>,
2165+
an <a>array</a> <var>containers</var> that represents an
21562166
ordered list of preferred <a>container mapping</a>,
21572167
a <a>string</a> <var>type/language</var> that indicates whether
21582168
to look for a <a>term</a> with a matching <a>type mapping</a>
2159-
or <a>language mapping</a>, and an <a>array</a> representing
2160-
an ordered list of <var>preferred values</var> for the <a>type mapping</a>
2161-
or <a>language mapping</a> to look for.</p>
2169+
or <a>language mapping</a>,
2170+
and an <a>array</a> representing an ordered list of <var>preferred values</var>
2171+
for the <a>type mapping</a> or <a>language mapping</a> to look for.</p>
21622172

21632173
<ol>
2174+
<li class="changed">If the <var>active context</var> has a `null`
2175+
<a data-lt='context-inverse'>inverse context</a>,
2176+
set <a data-lt='context-inverse'>inverse context</a> in <var>active context</var>
2177+
to the result of calling the
2178+
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
2179+
using <var>active context</var>.</li>
2180+
<li>Initialize <var>inverse context</var> to the value of
2181+
<a data-lt='context-inverse'>inverse context</a> in <var>active context</var>.</li>
21642182
<li>Initialize <var>container map</var> to the value associated with
21652183
<var>var</var> in the <var>inverse context</var>.</li>
21662184
<li>For each item <var>container</var> in <var>containers</var>:
@@ -3377,9 +3395,9 @@ <h3>Overview</h3>
33773395
<section class="algorithm">
33783396
<h3>Algorithm</h3>
33793397

3380-
<p>The algorithm takes <span class="changed">four required and two optional</span> input variables.
3398+
<p>The algorithm takes <span class="changed">three required and two optional</span> input variables.
33813399
The required inputs are an <var>active context</var>,
3382-
an <var>inverse context</var>, an <var>active property</var>,
3400+
an <var>active property</var>,
33833401
and an <var>element</var> to be compacted.
33843402
<span class="changed">The optional inputs are the
33853403
{{JsonLdOptions/compactArrays}} flag
@@ -3400,7 +3418,7 @@ <h3>Algorithm</h3>
34003418
<ol>
34013419
<li>Initialize <var>compacted item</var> to the result of using this
34023420
algorithm recursively, passing <var>active context</var>,
3403-
<var>inverse context</var>, <var>active property</var>,
3421+
<var>active property</var>,
34043422
<var>item</var> for <var>element</var>,
34053423
<span class="changed">and the {{JsonLdOptions/compactArrays}}
34063424
and {{JsonLdOptions/ordered}} flags</span>.</li>
@@ -3435,15 +3453,12 @@ <h3>Algorithm</h3>
34353453
<var>base URL</var> from the <a>term definition</a> for <var>active property</var>
34363454
in <var>active context</var>,
34373455
and <code>true</code> for <var>override protected</var></span>.</li>
3438-
<li>Set <var>inverse context</var> using the
3439-
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
3440-
using <var>active context</var>.</li>
34413456
</ol>
34423457
</li>
34433458
<li>If <var>element</var> has an <code>@value</code> or <code>@id</code>
34443459
<a>entry</a> and the result of using the
34453460
<a href="#value-compaction">Value Compaction algorithm</a>,
3446-
passing <var>active context</var>, <var>inverse context</var>,
3461+
passing <var>active context</var>,
34473462
<var>active property</var>, and <var>element</var> as <var>value</var> is
34483463
a <a>scalar</a>,
34493464
<span class="changed">or the <a>term definition</a> for <var>active property</var>
@@ -3453,7 +3468,7 @@ <h3>Algorithm</h3>
34533468
<a>list object</a>, and the <a>container mapping</a> for
34543469
<var>active property</var> in <var>active context</var> <span class="changed">includes</span> <code>@list</code>,
34553470
return the result of using this algorithm recursively, passing
3456-
<var>active context</var>, <var>inverse context</var>,
3471+
<var>active context</var>,
34573472
<var>active property</var>, value of <code>@list</code>
34583473
in <var>element</var> for <var>element</var>,
34593474
<span class="changed">and the {{JsonLdOptions/compactArrays}}
@@ -3471,19 +3486,14 @@ <h3>Algorithm</h3>
34713486
in <var>compacted types</var> ordered lexicographically:
34723487
<ol>
34733488
<li>If the <a>term definition</a> for <var>term</var> in <var>type-scoped context</var> has a
3474-
<a>local context</a>:
3475-
<ol>
3476-
<li>Set <var>active context</var> to the result of the
3477-
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
3478-
passing <var>active context</var> and the value of <var>term</var>'s
3479-
<a>local context</a> in <var>type-scoped context</var> as <var>local context</var>
3480-
<span class="changed">
3481-
<var>base URL</var> from the <a>term definition</a> for <var>term</var>
3482-
in <var>type-scoped context</var></span>.</li>
3483-
<li>Set <var>inverse context</var> using the
3484-
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
3485-
using <var>active context</var>.</li>
3486-
</ol>
3489+
<a>local context</a>
3490+
set <var>active context</var> to the result of the
3491+
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
3492+
passing <var>active context</var> and the value of <var>term</var>'s
3493+
<a>local context</a> in <var>type-scoped context</var> as <var>local context</var>
3494+
<span class="changed">
3495+
<var>base URL</var> from the <a>term definition</a> for <var>term</var>
3496+
in <var>type-scoped context</var></span>.
34873497
</li>
34883498
</ol>
34893499
</li>
@@ -3542,7 +3552,7 @@ <h3>Algorithm</h3>
35423552
<ol>
35433553
<li>Initialize <var>compacted value</var> to the result of using this
35443554
algorithm recursively, passing <var>active context</var>,
3545-
<var>inverse context</var>, <code>@reverse</code> for
3555+
<code>@reverse</code> for
35463556
<var>active property</var>, <var>expanded value</var>
35473557
for <var>element</var>,
35483558
<span class="changed">and the {{JsonLdOptions/compactArrays}}
@@ -3584,7 +3594,6 @@ <h3>Algorithm</h3>
35843594
<li>Initialize <var>compacted value</var> to the result of using this
35853595
algorithm recursively, passing
35863596
<var>active context</var>,
3587-
<var>inverse context</var>,
35883597
<var>active property</var>,
35893598
<var>expanded value</var> for <var>element</var>,
35903599
<span class="changed">and the {{JsonLdOptions/compactArrays}}
@@ -3670,7 +3679,7 @@ <h3>Algorithm</h3>
36703679
otherwise the negation of {{JsonLdOptions/compactArrays}}.</li>
36713680
<li>Initialize <var>compacted item</var> to the result of using
36723681
this algorithm recursively, passing
3673-
<var>active context</var>, <var>inverse context</var>,
3682+
<var>active context</var>,
36743683
<var>item active property</var> for <var>active property</var>,
36753684
<var>expanded item</var> for <var>element</var> if it does
36763685
not contain the <a>entry</a> <code>@list</code>
@@ -3827,7 +3836,7 @@ <h3>Algorithm</h3>
38273836
to `@id`, set <var>compacted item</var>
38283837
to the result of using
38293838
this algorithm recursively, passing
3830-
<var>active context</var>, <var>inverse context</var>,
3839+
<var>active context</var>,
38313840
<var>item active property</var> for <var>active property</var>,
38323841
and a <a>map</a> composed of the single <a>entry</a> for `@id` from <var>expanded item</var> for <var>element</var>.
38333842
<!-- Note: This will result in a string value, rather than a node object,
@@ -3913,8 +3922,8 @@ <h3>Overview</h3>
39133922
<section class="algorithm">
39143923
<h3>Algorithm</h3>
39153924

3916-
<p>This algorithm takes three required inputs and three optional inputs.
3917-
The required inputs are an <var>active context</var>, an <var>inverse context</var>,
3925+
<p>This algorithm takes <span class="changed">two</span> required inputs and three optional inputs.
3926+
The required inputs are an <var>active context</var>,
39183927
and the <var>var</var> to be compacted.
39193928
The optional inputs are a <var>value</var> associated with the <var>var</var>,
39203929
a <var>vocab</var> flag which specifies whether the passed <var>var</var>
@@ -3925,6 +3934,14 @@ <h3>Algorithm</h3>
39253934

39263935
<ol>
39273936
<li>If <var>var</var> is <code>null</code>, return <code>null</code>.</li>
3937+
<li class="changed">If the <var>active context</var> has a `null`
3938+
<a data-lt='context-inverse'>inverse context</a>,
3939+
set <a data-lt='context-inverse'>inverse context</a> in <var>active context</var>
3940+
to the result of calling the
3941+
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
3942+
using <var>active context</var>.</li>
3943+
<li>Initialize <var>inverse context</var> to the value of
3944+
<a data-lt='context-inverse'>inverse context</a> in <var>active context</var>.</li>
39283945
<li>If <var>vocab</var> is <code>true</code> and <var>var</var> is an
39293946
<a>entry</a> of <var>inverse context</var>:
39303947
<ol>
@@ -4134,7 +4151,7 @@ <h3>Algorithm</h3>
41344151
to <var>preferred values</var>.</li>
41354152
<li>Initialize <var>term</var> to the result of the
41364153
<a href="#term-selection">Term Selection algorithm</a>, passing
4137-
<var>inverse context</var>, <var>var</var>, <var>containers</var>,
4154+
<var>var</var>, <var>containers</var>,
41384155
<var>type/language</var>, and <var>preferred values</var>.</li>
41394156
<li>If <var>term</var> is not <code>null</code>, return <var>term</var>.</li>
41404157
</ol>
@@ -4238,12 +4255,20 @@ <h3>Overview</h3>
42384255
<section class="algorithm">
42394256
<h3>Algorithm</h3>
42404257

4241-
<p>This algorithm has four required inputs: an <var>active context</var>, an
4242-
<var>inverse context</var>, an <var>active property</var>, and a <var>value</var>
4258+
<p>This algorithm has <span class="changed">three</span> required inputs: an <var>active context</var>, an
4259+
an <var>active property</var>, and a <var>value</var>
42434260
to be compacted.</p>
42444261

42454262
<ol>
42464263
<li>Initialize <var>result</var> to a copy of <var>value</var>.</li>
4264+
<li class="changed">If the <var>active context</var> has a `null`
4265+
<a data-lt='context-inverse'>inverse context</a>,
4266+
set <a data-lt='context-inverse'>inverse context</a> in <var>active context</var>
4267+
to the result of calling the
4268+
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
4269+
using <var>active context</var>.</li>
4270+
<li>Initialize <var>inverse context</var> to the value of
4271+
<a data-lt='context-inverse'>inverse context</a> in <var>active context</var>.</li>
42474272
<li>Initialize <var>language</var> to the <a>language mapping</a> for <var>active property</var>
42484273
in <var>active context</var>, if any, otherwise to the <a>default language</a>
42494274
of <var>active context</var>.</li>
@@ -5695,15 +5720,12 @@ <h3>Algorithm</h3>
56955720
passing a new empty <a>context</a> as <var>active context</var>
56965721
<var>context</var> as <var>local context</var>,
56975722
and <var>context base</var> as <var>base URL</var>.</li>
5698-
<li>Initialize <var>inverse context</var> to the result of performing the
5699-
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>.</li>
57005723
<li>Initialize <a>base IRI</a> to the {{JsonLdOptions/base}} option from <a data-lt="jsonldprocessor-compact-options">options</a>, if set;
57015724
otherwise, if the <a data-link-for="JsonLdOptions">compactToRelative</a> option is <strong>true</strong>,
57025725
to the IRI of the currently being processed document, if available;
57035726
otherwise to <code>null</code>.</li>
57045727
<li>Set <var>compacted output</var> to the result of using the <a href="#compaction-algorithm">Compaction algorithm</a>,
57055728
using <a>active context</a>,
5706-
<var>inverse context</var>,
57075729
<code>null</code> for <var>active property</var>,
57085730
<var>expanded input</var> as <var>element</var>,
57095731
and the {{JsonLdOptions/compactArrays}}
@@ -6943,7 +6965,20 @@ <h2>Changes since Candidate Release of 12 December 2019</h2>
69436965
as a direct input, which resolves a {{Promise}} boundary issue.</li>
69446966
</ul>
69456967
</section>
6946-
6968+
<section class="appendix informative" id="changes-from-cr">
6969+
<h2>Changes since Candidate Release of 05 March 2020</h2>
6970+
<p class="note">All changes are editorial and do not affect the observable
6971+
behavior of the API nor the expected test results.</p>
6972+
<ul>
6973+
<li>The <a>inverse context</a> is not passed explicitly as a parameter
6974+
to the <a href="#term-selection">Term Selection</a>,
6975+
<a href="#iri-compaction">IRI compaction</a>,
6976+
and <a href="#value-compaction">Value Compaction</a> algorithms,
6977+
but is retrieved from the <a data-lt="context-inverse">inverse context</a> field
6978+
within an <a>active context</a>, and initialized as necessary.
6979+
This simplifies calling sequences and better represents actual implementation experience.
6980+
</ul>
6981+
</section>
69476982
<section id="ack"
69486983
class="appendix informative"
69496984
data-include="ack-script/acknowledgements.html"

0 commit comments

Comments
 (0)