Skip to content

Commit c0a1531

Browse files
committed
Update compaction algorithm.
1 parent 555b12a commit c0a1531

File tree

1 file changed

+87
-69
lines changed

1 file changed

+87
-69
lines changed

index.html

Lines changed: 87 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ <h3>Algorithm</h3>
18241824
</li>
18251825
<li>Otherwise <var>element</var> is a <a class="changed">dictionary</a>.</li>
18261826
<li class="changed">If <var>active context</var> has a <a>previous context</a>,
1827-
the <a>context</a> is type-scoped.
1827+
the <var>active context</var> is type-scoped.
18281828
If <var>from map</var> is undefined or <code>false</code>,
18291829
and <var>element</var> does not contain a <a>member</a> expanding to <code>@value</code>,
18301830
and <var>element</var> does not consist of a single member expanding to <code>@id</code>,
@@ -2492,19 +2492,9 @@ <h3>Algorithm</h3>
24922492
<span class="changed">If not passed, the both flags are set to <code>false</code></span>.</p>
24932493

24942494
<ol>
2495-
<li class="changed">If the <a>term definition</a> for <var>active property</var> has a
2496-
<a>local context</a>:
2497-
<ol>
2498-
<li>Set <var>active context</var> to the result of the
2499-
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
2500-
passing <var>active context</var>, the value of the
2501-
<var>active property</var>'s <a>local context</a> as <var>local context</var>,
2502-
<span class="changed">and <code>true</code> for <var>from property</var></span>.</li>
2503-
<li>Set <var>inverse context</var> using the
2504-
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
2505-
using <var>active context</var>.</li>
2506-
</ol>
2507-
</li>
2495+
<li class="changed">Set <var>type scoped context</var> to <var>active context</var>.
2496+
This is used for compacting values that may be relevant to any previous
2497+
type-scoped <a>context</a>.</li>
25082498
<li>If <var>element</var> is a <a>scalar</a>, it is already in its most
25092499
compact form, so simply return <var>element</var>.</li>
25102500
<li>If <var>element</var> is an <a>array</a>:
@@ -2534,8 +2524,27 @@ <h3>Algorithm</h3>
25342524
<li>Return <var>result</var>.</li>
25352525
</ol>
25362526
</li>
2537-
<li>Otherwise <var>element</var> is a <a class="changed">dictionary</a>.
2538-
If <var>element</var> has an <code>@value</code> or <code>@id</code>
2527+
<li>Otherwise <var>element</var> is a <a class="changed">dictionary</a>.</li>
2528+
<li class="changed">If <var>active context</var> has a <a>previous context</a>,
2529+
the <var>active context</var> is type-scoped.
2530+
If <var>element</var> does not contain an <code>@value</code> <a>member</a>,
2531+
and <var>element</var> does not consist of a single <code>@id</code> member,
2532+
set <var>active context</var> to <a>previous context</a> from <var>active context</var>,
2533+
as the scope of a term-scoped <a>context</a> does not apply when processing new <a>node objects</a>.</li>
2534+
<li class="changed">If the <a>term definition</a> for <var>active property</var> has a
2535+
<a>local context</a>:
2536+
<ol>
2537+
<li>Set <var>active context</var> to the result of the
2538+
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
2539+
passing <var>active context</var>, the value of the
2540+
<var>active property</var>'s <a>local context</a> as <var>local context</var>,
2541+
<span class="changed">and <code>true</code> for <var>from property</var></span>.</li>
2542+
<li>Set <var>inverse context</var> using the
2543+
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
2544+
using <var>active context</var>.</li>
2545+
</ol>
2546+
</li>
2547+
<li>If <var>element</var> has an <code>@value</code> or <code>@id</code>
25392548
<a>member</a> and the result of using the
25402549
<a href="#value-compaction">Value Compaction algorithm</a>,
25412550
passing <var>active context</var>, <var>inverse context</var>,
@@ -2557,9 +2566,6 @@ <h3>Algorithm</h3>
25572566
<var>active property</var> equals <code>@reverse</code>,
25582567
otherwise to <code>false</code>.</li>
25592568
<li>Initialize <var>result</var> to an empty <a class="changed">dictionary</a>.</li>
2560-
<li>Replace <var>active context</var> with the result of the
2561-
<a href="#revert-type-scoped-terms">Revert Type Scoped Terms</a> algorithm,
2562-
passing <var>active context</var>.</li>
25632569
<li class="changed">If <var>element</var> has a <code>@type</code> <a>member</a>,
25642570
create a new array <var>compacted types</var> initialized
25652571
by transforming each <var>expanded type</var> of that <a>member</a>
@@ -2570,13 +2576,13 @@ <h3>Algorithm</h3>
25702576
Then, for each <var>term</var>
25712577
in <var>compacted types</var> ordered lexicographically:
25722578
<ol>
2573-
<li>If the <a>term definition</a> for <var>term</var> has a
2579+
<li>If the <a>term definition</a> for <var>term</var> in <var>type scoped context</var> has a
25742580
<a>local context</a>:
25752581
<ol>
25762582
<li>Set <var>active context</var> to the result of the
25772583
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
25782584
passing <var>active context</var> and the value of <var>term</var>'s
2579-
<a>local context</a> as <var>local context</var>.</li>
2585+
<a>local context</a> in <var>type scoped context</var> as <var>local context</var>.</li>
25802586
<li>Set <var>inverse context</var> using the
25812587
<a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
25822588
using <var>active context</var>.</li>
@@ -2588,54 +2594,66 @@ <h3>Algorithm</h3>
25882594
in <var>element</var>, ordered lexicographically by <var>expanded property</var>
25892595
<span class="changed">if <a data-link-for="JsonLdOptions">ordered</a> is <code>true</code></span>:
25902596
<ol>
2591-
<li>If <var>expanded property</var> is <code>@id</code> or
2592-
<code>@type</code>:
2593-
<ol>
2594-
<li>If <var>expanded value</var> is a <a>string</a>,
2595-
then initialize <var>compacted value</var> to the result
2596-
of using the <a href="#iri-compaction">IRI Compaction algorithm</a>,
2597-
passing <var>active context</var>, <var>inverse context</var>,
2598-
<var>expanded value</var> for <var>var</var>,
2599-
and <code>true</code> for <var>vocab</var> if
2600-
<var>expanded property</var> is <code>@type</code>,
2601-
<code>false</code> otherwise.</li>
2602-
<li>Otherwise, <var>expanded value</var> must be a
2603-
<code>@type</code> <a>array</a>:
2604-
<ol>
2605-
<li>Initialize <var>compacted value</var> to an empty
2606-
<a>array</a>.</li>
2607-
<li>For each item <var>expanded type</var> in
2608-
<var>expanded value</var>:
2609-
<ol>
2610-
<li>Set <var>term</var> to the result of
2611-
of using the <a href="#iri-compaction">IRI Compaction algorithm</a>,
2612-
passing <var>active context</var>, <var>inverse context</var>,
2613-
<var>expanded type</var> for <var>var</var>, and
2614-
<code>true</code> for <var>vocab</var>.</li>
2615-
<li>Append <var>term</var>, to <var>compacted value</var>.</li>
2616-
</ol>
2617-
</li>
2618-
<li>If <var>compacted value</var> contains only one
2619-
item (it has a length of <code>1</code>), then
2620-
set <var>compacted value</var> to its only item.</li>
2621-
</ol>
2622-
</li>
2623-
<li>Initialize <var>alias</var> to the result of using the
2624-
<a href="#iri-compaction">IRI Compaction algorithm</a>,
2625-
passing <var>active context</var>, <var>inverse context</var>,
2626-
<var>expanded property</var> for <var>var</var>,
2627-
and <code>true</code> for <var>vocab</var>.</li>
2628-
<li class="changed">If <a>processing mode</a> is <code>json-ld-1.1</code>,
2629-
<var>element</var> does not have an <code>@value</code> member,
2630-
<var>expanded property</var> is <code>@type</code>,
2631-
and the <a>term definition</a> for <var>alias</var> in the
2632-
<var>active context</var> has a <a>container mapping</a> including <code>@set</code>,
2633-
ensure that <var>compacted value</var> is an <a>array</a>.</li>
2634-
<li>Add a <a>member</a> <var>alias</var> to <var>result</var> whose value is
2635-
set to <var>compacted value</var> and continue to the next
2636-
<var>expanded property</var>.</li>
2637-
</ol>
2638-
</li>
2597+
<li>If <var>expanded property</var> is <code>@id</code>:
2598+
<ol>
2599+
<li>If <var>expanded value</var> is a <a>string</a>,
2600+
then initialize <var>compacted value</var> to the result
2601+
of using the <a href="#iri-compaction">IRI Compaction algorithm</a>,
2602+
passing <var>active context</var>, <var>inverse context</var>,
2603+
and <var>expanded value</var> for <var>var</var>.</li>
2604+
<li>Initialize <var>alias</var> to the result of using the
2605+
<a href="#iri-compaction">IRI Compaction algorithm</a>,
2606+
passing <var>active context</var>, <var>inverse context</var>,
2607+
<var>expanded property</var> for <var>var</var>,
2608+
and <code>true</code> for <var>vocab</var>.</li>
2609+
<li>Add a <a>member</a> <var>alias</var> to <var>result</var> whose value is
2610+
set to <var>compacted value</var> and continue to the next
2611+
<var>expanded property</var>.</li>
2612+
</ol>
2613+
</li>
2614+
<li>If <var>expanded property</var> is <code>@type</code>:
2615+
<ol>
2616+
<li>If <var>expanded value</var> is a <a>string</a>,
2617+
then initialize <var>compacted value</var> to the result
2618+
of using the <a href="#iri-compaction">IRI Compaction algorithm</a>,
2619+
passing <var>type scoped context</var> for <var>active context</var>, <var>inverse context</var>,
2620+
<var>expanded value</var> for <var>var</var>,
2621+
and <code>true</code> for <var>vocab</var>.</li>
2622+
<li>Otherwise, <var>expanded value</var> must be a
2623+
<code>@type</code> <a>array</a>:
2624+
<ol>
2625+
<li>Initialize <var>compacted value</var> to an empty
2626+
<a>array</a>.</li>
2627+
<li>For each item <var>expanded type</var> in
2628+
<var>expanded value</var>:
2629+
<ol>
2630+
<li>Set <var>term</var> to the result of
2631+
of using the <a href="#iri-compaction">IRI Compaction algorithm</a>,
2632+
passing <var>type scoped context</var> for <var>active context</var>, <var>inverse context</var>,
2633+
<var>expanded type</var> for <var>var</var>, and
2634+
<code>true</code> for <var>vocab</var>.</li>
2635+
<li>Append <var>term</var>, to <var>compacted value</var>.</li>
2636+
</ol>
2637+
</li>
2638+
<li>If <var>compacted value</var> contains only one
2639+
item (it has a length of <code>1</code>), then
2640+
set <var>compacted value</var> to its only item.</li>
2641+
</ol>
2642+
</li>
2643+
<li>Initialize <var>alias</var> to the result of using the
2644+
<a href="#iri-compaction">IRI Compaction algorithm</a>,
2645+
passing <var>active context</var>, <var>inverse context</var>,
2646+
<var>expanded property</var> for <var>var</var>,
2647+
and <code>true</code> for <var>vocab</var>.</li>
2648+
<li class="changed">If <a>processing mode</a> is <code>json-ld-1.1</code>,
2649+
and the <a>term definition</a> for <var>alias</var> in the
2650+
<var>active context</var> has a <a>container mapping</a> including <code>@set</code>,
2651+
ensure that <var>compacted value</var> is an <a>array</a>.</li>
2652+
<li>Add a <a>member</a> <var>alias</var> to <var>result</var> whose value is
2653+
set to <var>compacted value</var> and continue to the next
2654+
<var>expanded property</var>.</li>
2655+
</ol>
2656+
</li>
26392657
<li>If <var>expanded property</var> is <code>@reverse</code>:
26402658
<ol>
26412659
<li>Initialize <var>compacted value</var> to the result of using this

0 commit comments

Comments
 (0)