Skip to content

Commit 3266f9f

Browse files
committed
Add support for @type: @none in term definitions.
* Updates value expansion and value compaction, inverse contexts, and term selection. * Causes all value objects which are not compacted away to have their keywords and value of `@type` compacted.
1 parent cad346a commit 3266f9f

15 files changed

+224
-6
lines changed

index.html

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,9 @@ <h3>Algorithm</h3>
12461246
<var>active context</var>, <var>type</var> for <var>value</var>,
12471247
<code>true</code> for <var>vocab</var>,
12481248
<var>local context</var>, and <var>defined</var>. If the expanded <var>type</var> is
1249-
neither <code>@id</code>, nor <code>@vocab</code>, nor an <a>absolute IRI</a>, an
1249+
neither <code>@id</code>, nor <code>@vocab</code>,
1250+
<span class="changed">nor, if <a>processing mode</a> is <code>json-ld-1.1</code>, <code>@none</code>,</span>
1251+
nor an <a>absolute IRI</a>, an
12501252
<a data-link-for="JsonLdErrorCode">invalid type mapping</a>
12511253
error has been detected and processing is aborted.</li>
12521254
<li>Set the <a>type mapping</a> for <var>definition</var> to <var>type</var>.</li>
@@ -2218,7 +2220,7 @@ <h3>Algorithm</h3>
22182220
<var>value</var>.</li>
22192221
<li>If <var>active property</var> has a <a>type mapping</a> in
22202222
<var>active context</var>,
2221-
<span class="changed">other than <code>@id</code> or <code>@vocab</code>,</span>
2223+
<span class="changed">other than <code>@id</code> or <code>@vocab</code>, or <code>@none</code>,</span>
22222224
add an <code>@type</code> <a>member</a> to
22232225
<var>result</var> and set its value to the value associated with the
22242226
<a>type mapping</a>.</li>
@@ -2935,6 +2937,22 @@ <h3>Algorithm</h3>
29352937
being processed.</li>
29362938
</ol>
29372939
</li>
2940+
<li class="changed">Otherwise, if <a>term definition</a> has a
2941+
<a>type mapping</a> which is <code>@null</code>:</li>
2942+
<ol>
2943+
<li>Reference the value associated with the <code>@language</code>
2944+
<a>member</a> in <var>type/language map</var> using the variable
2945+
<var>language map</var>.</li>
2946+
<li>If <var>language map</var> does not have an <code>@any</code>
2947+
<a>member</a>, create one and set its value to the <a>term</a>
2948+
being processed.</li>
2949+
<li>Reference the value associated with the <code>@type</code>
2950+
<a>member</a> in <var>type/language map</var> using the variable
2951+
<var>type map</var>.</li>
2952+
<li>If <var>type map</var> does not have an <code>@any</code>
2953+
<a>member</a>, create one and set its value to the <a>term</a>
2954+
being processed.</li>
2955+
</ol>
29382956
<li>Otherwise, if <a>term definition</a> has a
29392957
<a>type mapping</a>:
29402958
<ol>
@@ -3228,6 +3246,7 @@ <h3>Algorithm</h3>
32283246
that order, to <var>preferred values</var>.
32293247
<span class="changed">If <var>value</var> is an empty <a>list object</a>,
32303248
set <var>type/language</var> to <code>@any</code>.</span></li>
3249+
<li class="changed">Append <code>@any</code> to <var>preferred values</var>.</li>
32313250
<li>Initialize <var>term</var> to the result of the
32323251
<a href="#term-selection">Term Selection algorithm</a>, passing
32333252
<var>inverse context</var>, <var>var</var>, <var>containers</var>,
@@ -3558,6 +3577,22 @@ <h3>Algorithm</h3>
35583577
<code>1</code>.</li>
35593578
<li>If <var>number members</var> is greater than <code>2</code>, return
35603579
<var>value</var> as it cannot be compacted.</li>
3580+
<li class="changed">If the <a>type mapping</a> of <var>active property</var> is <code>@none</code>,
3581+
leave <var>value</var> as is, as value compaction is disabled.
3582+
<ol>
3583+
<li>Replace any value of <code>@type</code> in <var>value</var> with the result of using the
3584+
<a href="#iri-compaction">IRI compaction algorithm</a>,
3585+
passing <var>active context</var>, <var>inverse context</var>,
3586+
the value of the <code>@type</code> <a>member</a> for <var>var</var>, and
3587+
<code>true</code> for <var>vocab</var>.</li>
3588+
<li>Replace each key in <var>value</var> with the result of using the
3589+
<a href="#iri-compaction">IRI compaction algorithm</a>,
3590+
passing <var>active context</var>, <var>inverse context</var>,
3591+
the that key for <var>var</var>, and
3592+
<code>true</code> for <var>vocab</var>.</li>
3593+
<li>Return <var>value</var>.</li>
3594+
</ol>
3595+
</li>
35613596
<li>If <var>value</var> has an <code>@id</code> <a>member</a>:
35623597
<ol>
35633598
<li>If <var>number members</var> is <code>1</code> and
@@ -3590,7 +3625,21 @@ <h3>Algorithm</h3>
35903625
or the <a>language mapping</a> of <var>active property</var>
35913626
is set to <code>null</code>, return the value associated with the
35923627
<code>@value</code> <a>member</a>.</li>
3593-
<li>Otherwise, return <var>value</var> as is.</li>
3628+
<li>Otherwise:
3629+
<ol class="changed">
3630+
<li>Replace any value of <code>@type</code> in <var>value</var> with the result of using the
3631+
<a href="#iri-compaction">IRI compaction algorithm</a>,
3632+
passing <var>active context</var>, <var>inverse context</var>,
3633+
the value of the <code>@type</code> <a>member</a> for <var>var</var>, and
3634+
<code>true</code> for <var>vocab</var>.</li>
3635+
<li>Replace each key in <var>value</var> with the result of using the
3636+
<a href="#iri-compaction">IRI compaction algorithm</a>,
3637+
passing <var>active context</var>, <var>inverse context</var>,
3638+
the that key for <var>var</var>, and
3639+
<code>true</code> for <var>vocab</var>.</li>
3640+
<li>Return <var>value</var>.</li>
3641+
</ol>
3642+
</li>
35943643
</ol>
35953644
</section>
35963645
</section> <!-- end of Value Compaction algorithm -->
@@ -5570,11 +5619,9 @@ <h3>Security Considerations</h3>
55705619
<section class="appendix informative preserve">
55715620
<h2>Open Issues</h2>
55725621
<p>The following is a list of issues open at the time of publication.</p>
5573-
<p class="issue" data-number="4">Allow <code>@type</code> to have a <code>@container</code> specification, such as <code>@set</code>.</p>
55745622
<p class="issue" data-number="5">Define a "streaming profile" for JSON-LD to help parse data from a stream, rather than require the entire document to be in memory. Also to generate documents that can be so streamed. This would aid in using JSON-LD as a dataset dump format where there are a very large number of quads.</p>
55755623
<p class="issue" data-number="14">Problems importing contexts which reference other common contexts and result in an error.</p>
5576-
<p class="issue" data-number="26">For <code>@graph</code> containers, use the generated graph name identifier as the default subject for nodes in that graph.</p>
5577-
<p class="issue" data-number="33">Option to specify level of compaction for literals &amp; resources.</p>
5624+
<p class="issue" data-number="53">HTML baseURI and @context?</p>
55785625
</section>
55795626

55805627
<section class="appendix informative">
@@ -5683,6 +5730,7 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
56835730
<li>Added support for sealed <a>contexts</a> and <a>term definitions</a>.</li>
56845731
<li>Because scoped contexts can lead to contexts being reloaded, replace the
56855732
<strong>recursive context inclusion</strong> error with a <a data-link-for="JsonLdErrorCode">context overflow</a> error.</li>
5733+
<li>Added support for <code>"@type": "@none"</code> in a <a>term definition</a> to prevent value compaction.</li>
56865734
</ul>
56875735
</section>
56885736

tests/compact-manifest.jsonld

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,33 @@
15911591
"context": "compact/li05-context.jsonld",
15921592
"expect": "compact/li05-out.jsonld",
15931593
"option": {"specVersion": "json-ld-1.1"}
1594+
}, {
1595+
"@id": "#ttn01",
1596+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1597+
"name": "@type: @none does not compact values",
1598+
"purpose": "@type: @none does not compact values.",
1599+
"option": {"specVersion": "json-ld-1.1"},
1600+
"context": "compact/tn01-context.jsonld",
1601+
"input": "compact/tn01-in.jsonld",
1602+
"expect": "compact/tn01-out.jsonld"
1603+
}, {
1604+
"@id": "#ttn02",
1605+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1606+
"name": "@type: @none does not use arrays by default",
1607+
"purpose": "@type: @none honors @container.",
1608+
"option": {"specVersion": "json-ld-1.1"},
1609+
"context": "compact/tn02-context.jsonld",
1610+
"input": "compact/tn02-in.jsonld",
1611+
"expect": "compact/tn02-out.jsonld"
1612+
}, {
1613+
"@id": "#ttn03",
1614+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1615+
"name": "@type: @none uses arrays with @container: @set",
1616+
"purpose": "@type: @none honors @container.",
1617+
"option": {"specVersion": "json-ld-1.1"},
1618+
"context": "compact/tn03-context.jsonld",
1619+
"input": "compact/tn03-in.jsonld",
1620+
"expect": "compact/tn03-out.jsonld"
15941621
}
15951622
]
15961623
}

tests/compact/tn01-context.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"xsd": "http://www.w3.org/2001/XMLSchema#",
5+
"notype": {"@id": "http://example.com/notype", "@type": "@none"}
6+
}
7+
}

tests/compact/tn01-in.jsonld

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[{
2+
"http://example.com/notype": [
3+
{"@value": "string"},
4+
{"@value": true},
5+
{"@value": false},
6+
{"@value": 1},
7+
{"@value": 10.0},
8+
{"@value": "plain"},
9+
{"@value": true, "@type": "http://www.w3.org/2001/XMLSchema#boolean"},
10+
{"@value": "english", "@language": "en"},
11+
{"@value": "2018-02-17", "@type": "http://www.w3.org/2001/XMLSchema#date"},
12+
{"@id": "http://example.com/iri"}
13+
]
14+
}]

tests/compact/tn01-out.jsonld

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"xsd": "http://www.w3.org/2001/XMLSchema#",
5+
"notype": {"@id": "http://example.com/notype", "@type": "@none"}
6+
},
7+
"notype": [
8+
{"@value": "string"},
9+
{"@value": true},
10+
{"@value": false},
11+
{"@value": 1},
12+
{"@value": 10.0},
13+
{"@value": "plain"},
14+
{"@value": true, "@type": "xsd:boolean"},
15+
{"@value": "english", "@language": "en"},
16+
{"@value": "2018-02-17", "@type": "xsd:date"},
17+
{"@id": "http://example.com/iri"}
18+
]
19+
}

tests/compact/tn02-context.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"xsd": "http://www.w3.org/2001/XMLSchema#",
5+
"notype": {"@id": "http://example.com/notype", "@type": "@none"}
6+
}
7+
}

tests/compact/tn02-in.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"http://example.com/notype": [{"@value": "string"}]
3+
}]

tests/compact/tn02-out.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"xsd": "http://www.w3.org/2001/XMLSchema#",
5+
"notype": {"@id": "http://example.com/notype", "@type": "@none"}
6+
},
7+
"notype": {"@value": "string"}
8+
}

tests/compact/tn03-context.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"xsd": "http://www.w3.org/2001/XMLSchema#",
5+
"notype": {"@id": "http://example.com/notype", "@type": "@none", "@container": "@set"}
6+
}
7+
}

tests/compact/tn03-in.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"http://example.com/notype": [{"@value": "string"}]
3+
}]

tests/compact/tn03-out.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"xsd": "http://www.w3.org/2001/XMLSchema#",
5+
"notype": {"@id": "http://example.com/notype", "@type": "@none", "@container": "@set"}
6+
},
7+
"notype": [{"@value": "string"}]
8+
}

tests/expand-manifest.jsonld

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,22 @@
18501850
"option": {"specVersion": "json-ld-1.1"},
18511851
"input": "expand/se09-in.jsonld",
18521852
"expect": "expand/se09-out.jsonld"
1853+
}, {
1854+
"@id": "#ttn01",
1855+
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1856+
"name": "@type: @none is illegal in 1.0.",
1857+
"purpose": "@type: @none is illegal in json-ld-1.0.",
1858+
"option": {"specVersion": "json-ld-1.1"},
1859+
"input": "expand/tn01-in.jsonld",
1860+
"expect": "invalid type mapping"
1861+
}, {
1862+
"@id": "#ttn02",
1863+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1864+
"name": "@type: @none expands strings as value objects",
1865+
"purpose": "@type: @none leaves inputs other than strings alone",
1866+
"option": {"specVersion": "json-ld-1.1"},
1867+
"input": "expand/tn02-in.jsonld",
1868+
"expect": "expand/tn02-out.jsonld"
18531869
}
18541870
]
18551871
}

tests/expand/tn01-in.jsonld

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"@context": {
3+
"xsd": "http://www.w3.org/2001/XMLSchema#",
4+
"notype": {"@id": "http://example.com/notype", "@type": "@none"}
5+
},
6+
"notype": [
7+
"string",
8+
true,
9+
false,
10+
1,
11+
10.0,
12+
{"@value": "plain"},
13+
{"@value": true, "@type": "xsd:boolean"},
14+
{"@value": "english", "@language": "en"},
15+
{"@value": "2018-02-17", "@type": "xsd:date"},
16+
{"@id": "http://example.com/iri"}
17+
]
18+
}

tests/expand/tn02-in.jsonld

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"xsd": "http://www.w3.org/2001/XMLSchema#",
5+
"notype": {"@id": "http://example.com/notype", "@type": "@none"}
6+
},
7+
"notype": [
8+
"string",
9+
true,
10+
false,
11+
1,
12+
10.0,
13+
{"@value": "plain"},
14+
{"@value": true, "@type": "xsd:boolean"},
15+
{"@value": "english", "@language": "en"},
16+
{"@value": "2018-02-17", "@type": "xsd:date"},
17+
{"@id": "http://example.com/iri"}
18+
]
19+
}

tests/expand/tn02-out.jsonld

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[{
2+
"http://example.com/notype": [
3+
{"@value": "string"},
4+
{"@value": true},
5+
{"@value": false},
6+
{"@value": 1},
7+
{"@value": 10.0},
8+
{"@value": "plain"},
9+
{"@value": true, "@type": "http://www.w3.org/2001/XMLSchema#boolean"},
10+
{"@value": "english", "@language": "en"},
11+
{"@value": "2018-02-17", "@type": "http://www.w3.org/2001/XMLSchema#date"},
12+
{"@id": "http://example.com/iri"}
13+
]
14+
}]

0 commit comments

Comments
 (0)