Skip to content

Commit 555b12a

Browse files
committed
Update context processing and expansion algorithms for new type-scoped processing behavior.
1 parent 28491e3 commit 555b12a

File tree

1 file changed

+41
-60
lines changed

1 file changed

+41
-60
lines changed

index.html

Lines changed: 41 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -974,14 +974,13 @@ <h2>Context Processing Algorithm</h2>
974974
<p>The <a>active context</a> contains the active
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>,
977-
the <a>vocabulary mapping</a> and the <a>default language</a>. Each
978-
<a>term definition</a> consists of:</p>
977+
the <a>vocabulary mapping</a>, the <a>default language</a>,
978+
<span class="changed">and an optional <dfn>previous context</dfn>,
979+
used when a type-scoped <a>context</a> is defined</span>.
980+
Each <a>term definition</a> consists of:</p>
979981
<ul>
980982
<li>an <dfn>IRI mapping</dfn>,</li>
981983
<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>
985984
<li>an optional <dfn>type mapping</dfn>, or <dfn>language mapping</dfn>,</li>
986985
<li class="changed">an optional <a>context</a>,</li>
987986
<li class="changed">an optional <dfn>nest value</dfn>,</li>
@@ -1079,6 +1078,10 @@ <h3>Algorithm</h3>
10791078
<li>If <var>local context</var> is not an <a>array</a>,
10801079
set it to an <a>array</a> containing only
10811080
<var>local context</var>.</li>
1081+
<li class="changed">
1082+
If <var>from type</var> is <code>true</code>, and <var>result</var>
1083+
does not have a <a>previous context</a>, set <a>previous context</a>
1084+
in <var>result</var> to <var>active context</var>.</li>
10821085
<li>
10831086
For each item <var>context</var> in <var>local context</var>:
10841087
<ol>
@@ -1089,8 +1092,10 @@ <h3>Algorithm</h3>
10891092
an <a data-link-for="JsonLdErrorCode">invalid context nullification</a>
10901093
has been detected and processing is aborted.</li>
10911094
<li>Otherwise, set <var>result</var> to a
1092-
newly-initialized <var>active context</var> and continue with the
1093-
next <var>context</var>.
1095+
newly-initialized <var>active context</var>,
1096+
<span class="changed">setting <a>previous context</a> in <var>result</var>
1097+
to the previous value of <var>result</var> if <var>from type</var> is <code>true</code></span>.
1098+
Continue with the next <var>context</var>.
10941099
<span class="note">In JSON-LD 1.0, the <a>base IRI</a> was given
10951100
a default value here; this is now described conditionally
10961101
in <a href="#the-application-programming-interface" class="sectionRef"></a>.</span></li>
@@ -1275,8 +1280,7 @@ <h3>Algorithm</h3>
12751280
<var>protected</var> which defaults to <code>false</code>,
12761281
<var>from property</var>, defaulting to <code>false</code>,
12771282
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>.
1283+
and <var>from type</var>, defaulting to <code>false</code>.</span>.
12801284
</p>
12811285
<ol>
12821286
<li>If <var>defined</var> contains the <a>member</a> <var>term</var> and the associated
@@ -1314,8 +1318,6 @@ <h3>Algorithm</h3>
13141318
<code>@id</code>-<code>null</code>, set the
13151319
<a>term definition</a> in <var>active context</var> to
13161320
<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>
13191321
and set the value associated with <var>defined</var>'s
13201322
<a>member</a> <var>term</var> to <code>true</code>, and return.</li>
13211323
<li>Otherwise, if <var>value</var> is a <a>string</a>, convert it
@@ -1326,9 +1328,7 @@ <h3>Algorithm</h3>
13261328
<a data-link-for="JsonLdErrorCode">invalid term definition</a>
13271329
error has been detected and processing is aborted.
13281330
<span class="changed">Set <var>simple term</var> to <code>false</code></span>.</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>
1331+
<li>Create a new <a>term definition</a>, <var>definition</var>.</li>
13321332
<li class="changed">If the <code>@protected</code> member in <var>value</var>
13331333
is <code>true</code>, or there is no <code>@protected</code> member in <var>value</var>
13341334
and the <var>protected</var> parameter is <code>true</code>,
@@ -1559,34 +1559,6 @@ <h3>Algorithm</h3>
15591559
</section>
15601560
</section> <!-- end of Term Creation -->
15611561

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-
15901562
<section>
15911563
<h2>IRI Expansion</h2>
15921564

@@ -1808,10 +1780,16 @@ <h3>Algorithm</h3>
18081780
<li>If <var>element</var> is <code>null</code>, return <code>null</code>.</li>
18091781
<li class="changed">If <var>active property</var> is <code>@default</code>,
18101782
set the <a data-link-for="JsonLdOptions">frameExpansion</a> flag to <code>false</code>.</li>
1783+
<li class="changed">If <var>active property</var> has a <a>term definition</a> in <var>active context</var>
1784+
has a <a>local context</a>, set <var>property scoped context</var> to the that <a>local context</a>.</li>
18111785
<li>If <var>element</var> is a <a>scalar</a>,
18121786
<ol>
18131787
<li>If <var>active property</var> is <code>null</code> or <code>@graph</code>,
18141788
drop the free-floating <a>scalar</a> by returning <code>null</code>.</li>
1789+
<li class="changed">If <var>property scoped context</var> is defined,
1790+
set <var>active context</var> to the result of the
1791+
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
1792+
passing <var>active context</var> and <var>property scoped context</var> as <var>local context</var>.</li>
18151793
<li>Return the result of the
18161794
<a href="#value-expansion">Value Expansion algorithm</a>, passing the
18171795
<var>active context</var>, <var>active property</var>, and
@@ -1845,15 +1823,25 @@ <h3>Algorithm</h3>
18451823
</ol>
18461824
</li>
18471825
<li>Otherwise <var>element</var> is a <a class="changed">dictionary</a>.</li>
1826+
<li class="changed">If <var>active context</var> has a <a>previous context</a>,
1827+
the <a>context</a> is type-scoped.
1828+
If <var>from map</var> is undefined or <code>false</code>,
1829+
and <var>element</var> does not contain a <a>member</a> expanding to <code>@value</code>,
1830+
and <var>element</var> does not consist of a single member expanding to <code>@id</code>,
1831+
set <var>active context</var> to <a>previous context</a> from <var>active context</var>,
1832+
as the scope of a term-scoped <a>context</a> does not apply when processing new <a>node objects</a>.</li>
1833+
<li class="changed">If <var>property scoped context</var> is defined,
1834+
set <var>active context</var> to the result of the
1835+
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
1836+
passing <var>active context</var> and <var>property scoped context</var> as <var>local context</var>.</li>
18481837
<li>If <var>element</var> contains the <a>member</a> <code>@context</code>, set
18491838
<var>active context</var> to the result of the
18501839
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
18511840
passing <var>active context</var> and the value of the
18521841
<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>
1842+
<li class="changed">Set <var>type scoped context</var> to <var>active context</var>.
1843+
This is used for expanding values that may be relevant to any previous
1844+
type-scoped <a>context</a>.</li>
18571845
<li class="changed">For each <var>key</var>/<var>value</var> pair in <var>element</var>
18581846
where <var>key</var> expands to <code>@type</code> using the
18591847
<a href="#iri-expansion">IRI Expansion algorithm</a>,
@@ -1918,7 +1906,8 @@ <h3>Algorithm</h3>
19181906
error has been detected and processing is aborted. Otherwise,
19191907
set <var>expanded value</var> to the result of using the
19201908
<a href="#iri-expansion">IRI Expansion algorithm</a>, passing
1921-
<var>active context</var>, <code>true</code> for <var>vocab</var>,
1909+
<var class="changed">type scoped context</var> for <var>active context</var>,
1910+
<code>true</code> for <var>vocab</var>,
19221911
and <code>true</code> for <var>document relative</var> to expand the <var>value</var>
19231912
or each of its items.
19241913
<span class="changed">
@@ -2060,15 +2049,8 @@ <h3>Algorithm</h3>
20602049
<li>Continue with the next <var>key</var> from <var>element</var>.</li>
20612050
</ol>
20622051
</li>
2063-
<li class="changed">If <var>key</var>'s <a>term definition</a> in <var>active context</var>
2064-
has a <a>local context</a>, set <var>term context</var> to the result of the
2065-
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
2066-
passing <var>active context</var>, the value of the
2067-
<var>key</var>'s <a>local context</a> as <var>local context</var>,
2068-
and <code>true</code> for <var>from property</var>. Otherwise,
2069-
set <var>term context</var> to <var>active context</var>.</li>
20702052
<li>Set <var>container mapping</var> to <var>key</var>'s <a>container mapping</a> in
2071-
<var class="changed">term context</var>.</li>
2053+
<var>active context</var>.</li>
20722054
<li class="changed">If <var>key</var>'s <a>term definition</a> in <var>active context</var>
20732055
has a <a>type mapping</a> of <code>@json</code>,
20742056
set <var>expanded value</var> to a new <a>dictionary</a>, set the <a>member</a>
@@ -2123,9 +2105,8 @@ <h3>Algorithm</h3>
21232105
<ol>
21242106
<li class="changed">If <var>container mapping</var> includes <code>@type</code>:
21252107
<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>
2108+
<li>Set <var>map context</var> to the <a>previous context</a>
2109+
from <var>active context</var> if it exists, or <var>active context</var> otherwise.</li>
21292110
<li>If <var>index</var>'s <a>term definition</a> in
21302111
<var>map context</var> has a <a>local context</a>, update
21312112
<var>map context</var> to the result of the
@@ -2135,7 +2116,7 @@ <h3>Algorithm</h3>
21352116
as <var>local context</var>.</li>
21362117
</ol>
21372118
</li>
2138-
<li>Otherwise, set <var>map context</var> to <var>term context</var>.</li>
2119+
<li>Otherwise, set <var>map context</var> to <var>active context</var>.</li>
21392120
<li>Set <var>expanded index</var> to the result of using the
21402121
<a href="#iri-expansion">IRI Expansion algorithm</a>,
21412122
passing <var>active context</var>, <var>index</var>, and <code>true</code>
@@ -2195,7 +2176,7 @@ <h3>Algorithm</h3>
21952176
</ol>
21962177
</li>
21972178
<li>Otherwise, initialize <var>expanded value</var> to the result of
2198-
using this algorithm recursively, passing <var class="changed">term context</var> as <var>active context</var>,
2179+
using this algorithm recursively, passing <var>active context</var>,
21992180
<var>key</var> for <var>active property</var>, <var>value</var> for <var>element</var>,
22002181
<span class="changed">and the <a data-link-for="JsonLdOptions">frameExpansion</a>
22012182
and <a data-link-for="JsonLdOptions">ordered</a> flags</span>.</li>

0 commit comments

Comments
 (0)