Skip to content

Commit a5c9df9

Browse files
committed
Update context processing, compaction and expansion algorithms to keep type-scoped contexts strictly associated with objects with that type, and not sub-objects.
1 parent 74b2365 commit a5c9df9

File tree

1 file changed

+108
-45
lines changed

1 file changed

+108
-45
lines changed

index.html

Lines changed: 108 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -975,16 +975,23 @@ <h2>Context Processing Algorithm</h2>
975975
<a>term definitions</a> which specify how
976976
keys and values have to be interpreted as well as the current <a>base IRI</a>,
977977
the <a>vocabulary mapping</a> and the <a>default language</a>. Each
978-
<a>term definition</a> consists of an <dfn>IRI mapping</dfn>, a boolean
979-
flag <dfn>reverse property</dfn>, an optional <dfn>type mapping</dfn>
980-
or <dfn>language mapping</dfn>,
981-
<span class="changed">an optional <a>context</a></span>,
982-
<span class="changed">an optional <dfn>nest value</dfn>,</span>
983-
<span class="changed">an optional <dfn>prefix flag</dfn>,</span>
984-
<span class="changed">an optional <dfn>index mapping</dfn>,</span>
985-
<span class="changed">a <dfn>protected</dfn>, used to mark this as a protected term,</span>
986-
and an optional <dfn>container mapping</dfn>.
987-
A <a>term definition</a> can not only be used to map a <a>term</a>
978+
<a>term definition</a> consists of:</p>
979+
<ul>
980+
<li>an <dfn>IRI mapping</dfn>,</li>
981+
<li>a boolean flag <dfn>reverse property</dfn>,</li>
982+
<li class="changed">a boolean flag <dfn>from type</dfn>,</li>
983+
<li class="changed">a <dfn>previous definition</dfn>
984+
used to record any previous <a>term definition</a>,</li>
985+
<li>an optional <dfn>type mapping</dfn>, or <dfn>language mapping</dfn>,</li>
986+
<li class="changed">an optional <a>context</a>,</li>
987+
<li class="changed">an optional <dfn>nest value</dfn>,</li>
988+
<li class="changed">an optional <dfn>prefix flag</dfn>,</li>
989+
<li class="changed">an optional <dfn>index mapping</dfn>,</li>
990+
<li class="changed">a <dfn>protected</dfn>, used to mark this as a protected term,</li>
991+
<li>and an optional <dfn>container mapping</dfn></li>.
992+
</ul>
993+
994+
<p>A <a>term definition</a> can not only be used to map a <a>term</a>
988995
to an IRI, but also to map a <a>term</a> to a <a>keyword</a>,
989996
in which case it is referred to as a <dfn>keyword alias</dfn>.</p>
990997

@@ -1055,13 +1062,15 @@ <h3>Algorithm</h3>
10551062

10561063
<p>This algorithm specifies how a new <a>active context</a> is updated
10571064
with a <a>local context</a>. The algorithm takes two required
1058-
<span class="changed">and two optional</span>
1065+
<span class="changed">and three optional</span>
10591066
input variables.
10601067
The required inputs are an <var>active context</var> and a <var>local context</var>.
10611068
The optional inputs are an <a>array</a> <var>remote contexts</var>,
1062-
defaulting to a new empty <a>array</a>, which is used to detect cyclical context inclusions.
1063-
<span class="changed">and <var>from term</var>, defaulting to <code>false</code>,
1064-
which is used to allow changes to protected terms.</span>.
1069+
defaulting to a new empty <a>array</a>, which is used to detect cyclical context inclusions,
1070+
<span class="changed">, <var>from property</var>, defaulting to <code>false</code>,
1071+
which is used to allow changes to protected terms,
1072+
and <var>from type</var>, defaulting to <code>false</code>,
1073+
which is used to mark <a>term definitions</a> associated with a type-scoped <a>context</a>.</span>.
10651074
</p>
10661075

10671076
<ol>
@@ -1075,7 +1084,7 @@ <h3>Algorithm</h3>
10751084
<ol>
10761085
<li>If <var>context</var> is <code>null</code>:
10771086
<ol>
1078-
<li class="changed">If <var>from term</var> is <code>false</code> and <var>active context</var>
1087+
<li class="changed">If <var>from property</var> is <code>false</code> and <var>active context</var>
10791088
contains any <a>protected</a> <a>term definitions</a>,
10801089
an <a data-link-for="JsonLdErrorCode">invalid context nullification</a>
10811090
has been detected and processing is aborted.</li>
@@ -1213,7 +1222,7 @@ <h3>Algorithm</h3>
12131222
<var>defined</var>,
12141223
<span class="changed">the value of the <code>@protected</code>
12151224
member from <var>context</var>, if any, for <var>protected</var></span>,
1216-
and <var>from term</var>.</li>
1225+
<var>from property</var>, and <var>from type</var>.</li>
12171226
</ol>
12181227
</li>
12191228
<li>Return <var>result</var>.</li>
@@ -1258,14 +1267,16 @@ <h3>Overview</h3>
12581267
<section class="algorithm">
12591268
<h3>Algorithm</h3>
12601269

1261-
<p>The algorithm has four required <span class="changed">and two optional</span> inputs.
1270+
<p>The algorithm has four required <span class="changed">and three optional</span> inputs.
12621271
The required inputs are
12631272
an <var>active context</var>, a <var>local context</var>,
12641273
a <var>term</var>, and a map <var>defined</var>.
12651274
<span class="changed">The optional inputs are
12661275
<var>protected</var> which defaults to <code>false</code>,
1267-
and <var>from term</var>, defaulting to <code>false</code>,
1268-
which is used to allow changes to protected terms.</span>.
1276+
<var>from property</var>, defaulting to <code>false</code>,
1277+
which is used to allow changes to protected terms,
1278+
and <var>from type</var>, defaulting to <code>false</code>,
1279+
which is used to mark <a>term definitions</a> associated with a type-scoped <a>context</a>.</span>.
12691280
</p>
12701281
<ol>
12711282
<li>If <var>defined</var> contains the <a>member</a> <var>term</var> and the associated
@@ -1290,18 +1301,22 @@ <h3>Algorithm</h3>
12901301
<var>term</var> MUST NOT be a <a>keyword</a> and a
12911302
<a data-link-for="JsonLdErrorCode">keyword redefinition</a>
12921303
error has been detected and processing is aborted.</li>
1293-
<li class="changed">If <var>from term</var> is <code>false</code>
1294-
and <var>active context</var> has an existing
1295-
<a>term definition</a> for <var>term</var> which is protected,
1304+
<li class="changed">Set <var>previous definition</var> to any existing
1305+
<a>term definition</a> for <var>term</var> in <var>active context</var>.</li>
1306+
<li class="changed">If <var>from property</var> is <code>false</code>
1307+
and <var>previous definition</var> exists and is protected,
12961308
a <a data-link-for="JsonLdErrorCode">protected term redefinition</a> error has been detected,
12971309
and processing is aborted.</li>
1298-
<li>Otherwise, remove any existing <a>term definition</a> for <var>term</var> in
1310+
<li>Otherwise, remove any <var>previous definition</var> from
12991311
<var>active context</var>.</li>
13001312
<li>If <var>value</var> is <code>null</code> or <var>value</var>
13011313
is a <a class="changed">dictionary</a> containing the key-value pair
13021314
<code>@id</code>-<code>null</code>, set the
13031315
<a>term definition</a> in <var>active context</var> to
1304-
<code>null</code>, set the value associated with <var>defined</var>'s
1316+
<code>null</code>,
1317+
<span class="changed">along with <a>from type</a> from <var>from type</var>
1318+
and <a>previous definition</a> from <var>previous definition</var>,</span>
1319+
and set the value associated with <var>defined</var>'s
13051320
<a>member</a> <var>term</var> to <code>true</code>, and return.</li>
13061321
<li>Otherwise, if <var>value</var> is a <a>string</a>, convert it
13071322
to a <a class="changed">dictionary</a> consisting of a single <a>member</a> whose
@@ -1311,7 +1326,9 @@ <h3>Algorithm</h3>
13111326
<a data-link-for="JsonLdErrorCode">invalid term definition</a>
13121327
error has been detected and processing is aborted.
13131328
<span class="changed">Set <var>simple term</var> to <code>false</code></span>.</li>
1314-
<li>Create a new <a>term definition</a>, <var>definition</var>.</li>
1329+
<li>Create a new <a>term definition</a>, <var>definition</var>,
1330+
including <a>from type</a> from <var>from type</var>
1331+
and <a>previous definition</a> from <var>previous definition</var>.</li>
13151332
<li class="changed">If the <code>@protected</code> member in <var>value</var>
13161333
is <code>true</code>, or there is no <code>@protected</code> member in <var>value</var>
13171334
and the <var>protected</var> parameter is <code>true</code>,
@@ -1484,7 +1501,7 @@ <h3>Algorithm</h3>
14841501
<code>@context</code> <a>member</a>, which is treated as a <var>local context</var>.</li>
14851502
<li>Invoke the <a href="#context-processing-algorithm">Context Processing algorithm</a>
14861503
using the <var>active context</var>, <var>context</var> as <var>local context</var>,
1487-
and <code>true</code> for <var>from term</var>.
1504+
and <code>true</code> for <var>from property</var>.
14881505
If any error is detected, an
14891506
<a data-link-for="JsonLdErrorCode">invalid scoped context</a> error
14901507
has been detected and processing is aborted.</li>
@@ -1542,6 +1559,34 @@ <h3>Algorithm</h3>
15421559
</section>
15431560
</section> <!-- end of Term Creation -->
15441561

1562+
<section class="changed algorithm"><h2>Revert Type Scoped Terms</h2>
1563+
<p>This algorithm returns a new <a>context</a> based on the <a>active context</a>
1564+
where any <a>term definitions</a> which were created as part of a type-scoped <a>context</a>
1565+
are replaced with any previous term definitions, or removed.</p>
1566+
1567+
<p>The algorithm takes a single required parameter <var>active context</var></p>
1568+
<ol>
1569+
<li>If <var>active context</var> contains no <a>term definitions</a>
1570+
where <var>from type</var> is <code>true</code>, return <var>active context</var>.</li>
1571+
<li>Initialize <var>result</var> to the result of cloning <var>active context</var>.</li>
1572+
<li>For each <a>member</a> <a>term definition</a> with key <var>term</var> and value <var>definition</var> in <var>result</var>:
1573+
<ol>
1574+
<li>If <var>definition</var> has <var>from type</var> with a value of <code>true</code>:
1575+
<ol>
1576+
<li>Set <var>previous definition</var> to any <a>previous definition</a>
1577+
in <var>definition</var>.</li>
1578+
<li>If <var>previous definition</var> is undefined,
1579+
remove <var>term</var> and <var>definition</var> from <var>result</var>.</li>
1580+
<li>Otherwise, update the <a>member</a> value for <var>term</var> in <var>result</var>
1581+
with <var>previous definition</var>.</li>
1582+
</ol>
1583+
</li>
1584+
</ol>
1585+
</li>
1586+
<li>Return <var>result</var>.</li>
1587+
</ol>
1588+
</section>
1589+
15451590
<section>
15461591
<h2>IRI Expansion</h2>
15471592

@@ -1723,14 +1768,16 @@ <h3>Overview</h3>
17231768
<section class="algorithm">
17241769
<h3>Algorithm</h3>
17251770

1726-
<p>The algorithm takes three required <span class="changed">and two optional</span> input variables.
1771+
<p>The algorithm takes three required <span class="changed">and three optional</span> input variables.
17271772
The required inputs are an <var>active context</var>,
17281773
an <var>active property</var>, and an <var>element</var> to be expanded.
17291774
<span class="changed">The optional inputs are the
17301775
<a data-link-for="JsonLdOptions">frameExpansion</a>
17311776
flag allowing special forms of input used for <a data-cite="JSON-LD11-FRAMING#dfn-framing">frame expansion</a>,
1732-
and the <a data-link-for="JsonLdOptions">ordered</a> flag, used to order
1733-
<a>dictionary member</a> keys lexicographically, where noted</span>.
1777+
the <a data-link-for="JsonLdOptions">ordered</a> flag, used to order
1778+
<a>dictionary member</a> keys lexicographically, where noted,
1779+
and the <var>from map</var> flag, used to control reverting
1780+
previous <a>term definitions</a> in the <a>active context</a> associated with a type-scoped <a>context</a>.</span>
17341781
To begin, the <var>active property</var> is set to <code>null</code>,
17351782
and <var>element</var> is set to the <a>JSON-LD input</a>.
17361783
<span class="changed">If not passed, the both flags are set to <code>false</code></span>.</p>
@@ -1780,7 +1827,8 @@ <h3>Algorithm</h3>
17801827
algorithm recursively, passing <var>active context</var>,
17811828
<var>active property</var>, <var>item</var> as <var>element</var>,
17821829
<span class="changed">the <a data-link-for="JsonLdOptions">frameExpansion</a>
1783-
and <a data-link-for="JsonLdOptions">ordered</a></span> flags.</li>
1830+
<a data-link-for="JsonLdOptions">ordered</a></span>,
1831+
and <var>from map</var> flags.</li>
17841832
<li class="changed">If the <a>container mapping</a>
17851833
of <var>active property</var> includes <code>@list</code>,
17861834
and <var>expanded item</var> is an
@@ -1802,6 +1850,10 @@ <h3>Algorithm</h3>
18021850
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
18031851
passing <var>active context</var> and the value of the
18041852
<code>@context</code> <a>member</a> as <var>local context</var>.</li>
1853+
<li>Unless the <var>from map</var> flag is true,
1854+
replace <var>active context</var> with the result of the
1855+
<a href="#revert-type-scoped-terms">Revert Type Scoped Terms</a> algorithm,
1856+
passing <var>active context</var>.</li>
18051857
<li class="changed">For each <var>key</var>/<var>value</var> pair in <var>element</var>
18061858
where <var>key</var> expands to <code>@type</code> using the
18071859
<a href="#iri-expansion">IRI Expansion algorithm</a>,
@@ -1813,8 +1865,9 @@ <h3>Algorithm</h3>
18131865
has a <a>local context</a>, set <var>active context</var> to the result
18141866
to the result of the
18151867
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
1816-
passing <var>active context</var> and the value of the
1817-
<var>term</var>'s <a>local context</a> as <var>local context</var>.</li>
1868+
passing <var>active context</var>, the value of the
1869+
<var>term</var>'s <a>local context</a> as <var>local context</var>,
1870+
<span class="changed">and <code>true</code> for <var>from type</var></span>.</li>
18181871
</ol>
18191872
</li>
18201873
<li>Initialize an empty <a class="changed">dictionary</a>, <var>result</var>.</li>
@@ -2012,7 +2065,7 @@ <h3>Algorithm</h3>
20122065
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
20132066
passing <var>active context</var>, the value of the
20142067
<var>key</var>'s <a>local context</a> as <var>local context</var>,
2015-
and <code>true</code> for <var>from term</var>. Otherwise,
2068+
and <code>true</code> for <var>from property</var>. Otherwise,
20162069
set <var>term context</var> to <var>active context</var>.</li>
20172070
<li>Set <var>container mapping</var> to <var>key</var>'s <a>container mapping</a> in
20182071
<var class="changed">term context</var>.</li>
@@ -2068,15 +2121,21 @@ <h3>Algorithm</h3>
20682121
in <var>value</var>, ordered lexicographically by <var>index</var>
20692122
<span class="changed">if <a data-link-for="JsonLdOptions">ordered</a> is <code>true</code></span>:
20702123
<ol>
2071-
<li class="changed">If <var>container mapping</var> includes <code>@type</code>,
2072-
and <var>index</var>'s <a>term definition</a> in
2073-
<var>term context</var> has a <a>local context</a>, set
2074-
<var>map context</var> to the result of the <a
2075-
href="#context-processing-algorithm">Context Processing
2076-
algorithm</a>, passing <var>term context</var> as <var>active context</var> and the
2077-
value of the <var>index</var>'s <a>local context</a> as
2078-
<var>local context</var>. Otherwise, set <var>map context</var>
2079-
to <var>term context</var>.</li>
2124+
<li class="changed">If <var>container mapping</var> includes <code>@type</code>:
2125+
<ol>
2126+
<li>Set <var>map context</var> to the result of calling the
2127+
<a href="#revert-type-scoped-terms">Revert Type Scoped Terms</a> algorithm
2128+
passing <var>term context</var> as <var>active context</var>.</li>
2129+
<li>If <var>index</var>'s <a>term definition</a> in
2130+
<var>map context</var> has a <a>local context</a>, update
2131+
<var>map context</var> to the result of the
2132+
<a href="#context-processing-algorithm">Context Processingalgorithm</a>,
2133+
passing <var>map context</var> as <var>active context</var>
2134+
and the value of the <var>index</var>'s <a>local context</a>
2135+
as <var>local context</var>.</li>
2136+
</ol>
2137+
</li>
2138+
<li>Otherwise, set <var>map context</var> to <var>term context</var>.</li>
20802139
<li>Set <var>expanded index</var> to the result of using the
20812140
<a href="#iri-expansion">IRI Expansion algorithm</a>,
20822141
passing <var>active context</var>, <var>index</var>, and <code>true</code>
@@ -2459,7 +2518,7 @@ <h3>Algorithm</h3>
24592518
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
24602519
passing <var>active context</var>, the value of the
24612520
<var>active property</var>'s <a>local context</a> as <var>local context</var>,
2462-
<span class="changed">and <code>true</code> for <var>from term</var></span>.</li>
2521+
<span class="changed">and <code>true</code> for <var>from property</var></span>.</li>
24632522
<li>Set <var>inverse context</var> using the
24642523
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
24652524
using <var>active context</var>.</li>
@@ -2517,13 +2576,17 @@ <h3>Algorithm</h3>
25172576
<var>active property</var> equals <code>@reverse</code>,
25182577
otherwise to <code>false</code>.</li>
25192578
<li>Initialize <var>result</var> to an empty <a class="changed">dictionary</a>.</li>
2579+
<li>Replace <var>active context</var> with the result of the
2580+
<a href="#revert-type-scoped-terms">Revert Type Scoped Terms</a> algorithm,
2581+
passing <var>active context</var>.</li>
25202582
<li class="changed">If <var>element</var> has a <code>@type</code> <a>member</a>,
25212583
create a new array <var>compacted types</var> initialized
25222584
by transforming each <var>expanded type</var> of that <a>member</a>
25232585
into it's compacted form using the <a href="#iri-compaction">IRI Compaction algorithm</a>,
25242586
passing <var>active context</var>, <var>inverse context</var>,
2525-
<var>expanded type</var> for <var>var</var>, and
2526-
<code>true</code> for <var>vocab</var>. Then, for each <var>term</var>
2587+
<var>expanded type</var> for <var>var</var>, <code>true</code> for <var>vocab</var>,
2588+
and <code>true</code> for <var>from type</var>.
2589+
Then, for each <var>term</var>
25272590
in <var>compacted types</var> ordered lexicographically:
25282591
<ol>
25292592
<li>If the <a>term definition</a> for <var>term</var> has a

0 commit comments

Comments
 (0)