Skip to content

Commit 51de407

Browse files
committed
Added spec text to resolve ISSUE-133 - adding @language container. Close #133.
1 parent 2677464 commit 51de407

File tree

2 files changed

+55
-23
lines changed

2 files changed

+55
-23
lines changed

spec/latest/json-ld-api/index.html

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,8 @@ <h2 id="context">Context Processing</h2>
11811181
Determine the IRI by performing <a href="#iri-expansion">IRI Expansion</a> on the associated value.
11821182
If the result of the IRI mapping is an <tref>absolute IRI</tref> or <code>@id</code>, merge into the
11831183
<tref>local context</tref> <tref>coercion mapping</tref> using the lexical value of the <em>property</em>.</li>
1184-
<li>If the <em>value</em> has a <code>@container</code> property, its value MUST be <code>@list</code> or
1185-
<code>@set</code>. Merge the <tref>list mapping</tref> or <tref>set mapping</tref> into the
1184+
<li>If the <em>value</em> has a <code>@container</code> property, its value MUST be <code>@list</code>,
1185+
<code>@set</code>, or <code>@language</code>. Merge the <tref>list mapping</tref> or <tref>set mapping</tref> into the
11861186
<tref>local context</tref> using the lexical value of the <em>property</em>.</li>
11871187
<li>If the <em>value</em> has a <code>@language</code> property but no <code>@type</code> property, the value of the
11881188
<code>@language</code> property MUST be a <tref>string</tref> or <tref>null</tref>.
@@ -1337,7 +1337,7 @@ <h3>Term Rank Algorithm</h3>
13371337
<li>Otherwise, return the sum of the <tref>term rank</tref>s for every entry in the list.</li>
13381338
</ol>
13391339
</li>
1340-
<li>Otherwise, <em>value</em> MUST be a <tref>node object</tref>, <tref>node object</tref>,
1340+
<li>Otherwise, <em>value</em> MUST be a <tref>node object</tref>,
13411341
or a <tref>JSON object</tref> having a <code>@value</code>.
13421342
<ol class="algorithm">
13431343
<li>If <em>value</em> has a <code>@value</code> property:
@@ -1353,6 +1353,11 @@ <h3>Term Rank Algorithm</h3>
13531353
<code>@language</code> <tref>null</tref> or ((<em>term</em> has no <code>@type</code> or
13541354
<code>@language</code>) and the <tref>active context</tref> has no <code>@language</code>),
13551355
<tref>term rank</tref> is <code>3</code>, otherwise <code>0</code>.</li>
1356+
<li>Otherwise, if <em>value</em> has only a <code>@value</code> and <code>@language</code> property
1357+
and <em>term</em> has a <code>@container</code> key associated with a value of
1358+
<code>@language</code> in the <tref>active context</tref>,
1359+
<tref>term rank</tref> is <code>1</code>,
1360+
otherwise <code>-Infinity</code>.</li>
13561361
<li>Otherwise, if <em>value</em> has a <code>@language</code> property matching a
13571362
<code>@language</code> definition for <em>term</em> or
13581363
((<em>term</em> has no <code>@type</code> or <code>@language</code> definition) and
@@ -1536,10 +1541,31 @@ <h3>Expansion Algorithm</h3>
15361541
If <em>property</em> is <code>@list</code> and any entry in <em>value</em> is a
15371542
<tref>JSON object</tref> containing an <code>@list</code> property, return an error, as
15381543
lists of lists are not supported.</li>
1544+
<li>Otherwise, if the <em>property</em> is not a keyword and its associated <tref>term</tref> entry in
1545+
the <tref>active context</tref> has a <code>@container</code> key associated with a value of <code>@language</code>,
1546+
process the associated <em>value</em> as a <em>language map</em>:
1547+
<ol class="algorithm">
1548+
<li>Set <em>multilingual array</em> to an empty array.</li>
1549+
<li>For each key-value in the <em>language map</em>:
1550+
<ol class="algorithm">
1551+
<li>Create a new <tref>JSON Object</tref>, referred to as an <em>expanded language object</em>.
1552+
<li>Add a key-value pair to the <em>expanded language object</em> where the
1553+
key is <code>@value</code> and the value is
1554+
the value associated with the key in the <em>language map</em>.</li>
1555+
<li>Add a key-value pair to the <em>expanded language object</em> where the
1556+
key is <code>@language</code>, and the value is the key in the
1557+
<em>language map</em>, transformed to lowercase.
1558+
</li>
1559+
<li>Append the <em>expanded language object</em> to the <em>multilingual array</em>.
1560+
</ol>
1561+
</li>
1562+
<li>Set the <em>value</em> associated with <em>property</em> to the <em>multilingual array</em>.</li>
1563+
</ol>
1564+
</li>
15391565
<li>Otherwise, expand <em>value</em> recursively using this algorithm, passing copies of the <tref>active context</tref> and
15401566
<tref>active property</tref>.</li>
15411567
<li>If <em>property</em> is not a keyword
1542-
and <tref>active property</tref> has a <code>@container</code> <code>@list</code>
1568+
and <tref>active property</tref> has a <code>@container</code> key associated with a value of <code>@list</code>
15431569
and the expanded <em>value</em> is not <tref>null</tref>,
15441570
convert <em>value</em> to an <tref>object</tref> with an <code>@list</code> property whose value is
15451571
set to <em>value</em> (unless <em>value</em> is already in that form).</li>
@@ -1702,6 +1728,23 @@ <h3>Compaction Algorithm</h3>
17021728
<li>Create an entry in <em>output</em> for <tref>active property</tref> and <em>value</em>.</li>
17031729
</ol>
17041730
</li>
1731+
<li>If the <em>value</em> is an <tref>array</tref> and <tref>property</tref> is
1732+
a <tref>term</tref> in the <tref>active context</tref> that contains a
1733+
<code>@container</code> key associated with a value of <code>@language</code>, process
1734+
the <em>value</em> as a <em>multilingual array</em>:
1735+
<ol class="algorithm">
1736+
<li>Set <em>language map</em> to an empty <tref>JSON Object</tref>.</li>
1737+
<li>For each <em>item</em> in <em>multilingual array</em>, add a key-value
1738+
pair to the <em>language map</em> where the key
1739+
is the value associated with the <code>@language</code> key in
1740+
<em>item</em>, and the value is the value associated with the
1741+
<code>@value</code> key in <em>item</em>.</li>
1742+
</li>
1743+
<li>Create an entry in <em>output</em> for <tref>active property</tref> and
1744+
<em>language map</em>, appending to an existing entry if necessary.
1745+
</li>
1746+
</ol>
1747+
</li>
17051748
<li>For each <em>item</em> in <em>value</em>:
17061749
<ol class="algorithm">
17071750
<li>Set <tref>active property</tref> to the result of performing <a href="#iri-compaction">IRI Compaction</a>

spec/latest/json-ld-syntax/index.html

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,6 @@ <h2>JSON-LD Grammar</h2>
25872587
previous sections more formally.</p>
25882588

25892589
<p class="note">The JSON-LD context allows <tref title="keyword">keywords</tref>
2590-
to be aliased within the <tref>active context</tref> (see
25912590
<a href="#aliasing-keywords"></a>). Whenever a <tref>keyword</tref> is
25922591
discussed in this grammar, this is also understood to apply to an alias for
25932592
that <tref>keyword</tref>. For example, if the <tref>active context</tref>
@@ -2729,26 +2728,16 @@ <h2>Term</h2>
27292728
<section id="grammar-language-map">
27302729
<h2>Language Map</h2>
27312730
<p>A <tdef>language map</tdef> is used to associate a language with a value in a
2732-
way that allows easy programmatic access.</p>
2733-
2734-
<p>A <tref>language map</tref> may be used as a term value within a
2735-
<tref>node object</tref> if the term is defined with
2736-
<code>@container</code> set to <code>@language</code>.</p>
2737-
2738-
<p>The keys of a <tref>language map</tref> MUST be [[BCP47]] <tref title="string">strings</tref>
2739-
with an associated value that is any of the following types:</p>
2731+
way that allows easy programmatic access. A <tref>language map</tref> may be
2732+
used as a term value within a <tref>node object</tref> if the term is defined
2733+
with <code>@container</code> set to <code>@language</code>. The keys of a
2734+
<tref>language map</tref> MUST be lowercase [[BCP47]]
2735+
<tref title="string">strings</tref> with an associated value that is any
2736+
of the following types:</p>
27402737
<ul>
2741-
<li><tref>string</tref>,</li>
2742-
<li><tref>number</tref>,</li>
2743-
<li><tref>true</tref>,</li>
2744-
<li><tref>false</tref>,</li>
2745-
<li><tref>null</tref>,</li>
2746-
<li><tref>node object</tref>,</li>
2747-
<li><tref>expanded typed value</tref>,</li>
2748-
<li><tref>list</tref> or <tref>set</tref>, or</li>
2749-
<li>an <tref>array</tref> zero or more of these</li>
2738+
<li><tref>string</tref>, or</li>
2739+
<li>an <tref>array</tref> of zero or more strings</li>
27502740
</ul>
2751-
<p class="issue" data-number="133">We are also discussing values other than strings, such as those that might represent a more reified version of a value with other properties, such as is described using <a href="http://www.w3.org/TR/skos-reference/skos-xl.html">SKOS-XL</a>.</p>
27522741
<p>See <a href="#language-tagged-strings"></a> for further discussion on language maps.</p>
27532742
</section>
27542743

0 commit comments

Comments
 (0)