Skip to content

Commit 3164dfe

Browse files
authored
Merge pull request #501 from json-ld/issue-496-preserve-expansion
Update IRI Compaction, Compaction, and Remove Preserve logic to cause…
2 parents f7b7360 + 9cc3418 commit 3164dfe

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,18 @@ <h3>Algorithm</h3>
20962096
<li>Continue with the next <em>expanded property</em> from <em>element</em>.</li>
20972097
</ol>
20982098
</li>
2099+
<li class="changed">If <em>expanded property</em> is <code>@preserve</code>
2100+
then:
2101+
<ol class="algorithm">
2102+
<li>Initialize <em>compacted value</em> to the result of using this
2103+
algorithm recursively, passing <a>active context</a>,
2104+
<a>inverse context</a>, <em>property</em> for
2105+
<a>active property</a>, and <em>expanded value</em>
2106+
for <em>element</em>.</li>
2107+
<li>Add <em>expanded value</em> as the value of <code>@preserve</code>
2108+
in <em>result</em> unless <em>expanded value</em> is an empty <a>array</a>.</li>
2109+
</ol>
2110+
</li>
20992111
<li>If <em>expanded property</em> is <code>@index</code> and
21002112
<a>active property</a> has a <a>container mapping</a>
21012113
in <a>active context</a> that is <code>@index</code>,
@@ -2530,6 +2542,9 @@ <h3>Algorithm</h3>
25302542
<a data-lt="active context">active context's</a>
25312543
<a>default language</a>, if it has one, otherwise to
25322544
<code>@none</code>.</li>
2545+
<li class="changed">If <em>value</em> is a <a>dictionary</a> containing
2546+
the property <code>@preserve</code>, use the first
2547+
element from the value of <code>@preserve</code> as <em>value</em>.</li>
25332548
<li>Initialize <em>containers</em> to an empty <a>array</a>. This
25342549
<a>array</a> will be used to keep track of an ordered list of
25352550
preferred <a>container mapping</a>
@@ -4529,6 +4544,7 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
45294544
<li>The JSON syntax has been abstracted into an <a>internal representation</a>
45304545
to allow for other seriazation formats that are functionally equivalent
45314546
to JSON.</li>
4547+
<li>Preserved values are compacted using the properties of the referencing term.</li>
45324548
<li>The value for <code>@container</code> in an <a>expanded term definition</a>
45334549
can also be an <a>array</a> containing any appropriate container
45344550
keyword along with <code>@set</code> (other than <code>@list</code>).

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ <h3>Framing Algorithm</h3>
10561056
<p>Recursively, replace all key-value pairs in <em>compacted results</em>
10571057
where the key is <code>@preserve</code> with the value from the key-pair.
10581058
If the value from the key-pair is <code>@null</code>, replace the value with <code>null</code>.
1059+
<span class="changed">If, after replacement, an array contains a single array value, replace the array with that value.</span>
10591060
If, after replacement, an array contains only the value <a>null</a> remove the value, leaving
10601061
an empty <a>array</a>.</p>
10611062
<p>Return <em>compacted results</em>.</p>
@@ -1478,6 +1479,7 @@ <h2>Changes since 1.0 Draft of 30 August 2012</h2>
14781479
<li>The JSON syntax has been abstracted into an <a>internal representation</a>
14791480
to allow for other seriazation formats that are functionally equivalent
14801481
to JSON.</li>
1482+
<li>Preserved values are compacted using the properties of the referencing term.</li>
14811483
</ul>
14821484
</section>
14831485

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"@context": {
3+
"schema": "http://schema.org/",
4+
"name": "schema:name",
5+
"url": { "@id": "schema:url", "@type": "schema:URL"}
6+
},
7+
"name": {},
8+
"url": {"@default": {"@value": "http://example.com", "@type": "schema:URL"}}
9+
}

test-suite/tests/frame-0051-in.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"schema": "http://schema.org/",
4+
"name": "schema:name",
5+
"url": {"@id": "schema:url", "@type": "schema:URL"}
6+
},
7+
"name": "Jane Doe"
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"@context": {
3+
"schema": "http://schema.org/",
4+
"name": "schema:name",
5+
"url": {
6+
"@id": "schema:url",
7+
"@type": "schema:URL"
8+
}
9+
},
10+
"@graph": [
11+
{
12+
"name": "Jane Doe",
13+
"url": "http://example.com"
14+
}
15+
]
16+
}

test-suite/tests/frame-manifest.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,14 @@
409409
"input": "frame-0050-in.jsonld",
410410
"frame": "frame-0050-frame.jsonld",
411411
"expect": "frame-0050-out.jsonld"
412+
}, {
413+
"@id": "#t0051",
414+
"@type": ["jld:PositiveEvaluationTest", "jld:FrameTest"],
415+
"name": "Compacting values of @preserve",
416+
"purpose": "When compacting the value of a property using @preserve, use the term definition for term to properly compact the value of @preserve.",
417+
"input": "frame-0051-in.jsonld",
418+
"frame": "frame-0051-frame.jsonld",
419+
"expect": "frame-0051-out.jsonld"
412420
}, {
413421
"@id": "#tp010",
414422
"@type": ["jld:PositiveEvaluationTest", "jld:FrameTest"],

0 commit comments

Comments
 (0)