Skip to content

Commit 0b7f507

Browse files
authored
Merge pull request #511 from json-ld/issue-405-468
compactToRelative option and updates to compact IRI creation
2 parents 772b818 + f87ef0e commit 0b7f507

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+927
-471
lines changed

spec/latest/common/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var jsonld = {
1212
},
1313
"JSON-LD-API": {
1414
title: "JSON-LD 1.1 Processing Algorithms and API",
15-
href: "http://json-ld.org/spec/latest/json-ld/",
15+
href: "http://json-ld.org/spec/latest/json-ld-api/",
1616
authors: ["Markus Lanthaler", "Gregg Kellogg", "Manu Sporny"],
1717
publisher: "W3C",
1818
status: 'CG Draft'

spec/latest/common/terms.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ <h1>General Terminology</h1>
213213
<dt><dfn data-lt="objects">object</dfn></dt><dd>
214214
An <a data-cite="RDF11-CONCEPTS#dfn-object" class="externalDFN">object</a> is a <a>node</a> in a <a>linked data graph</a> with at least one incoming edge.
215215
See <dfn data-cite="RDF11-CONCEPTS#dfn-object" class="preserve">RDF object</dfn>in [[RDF11-CONCEPTS]].</dd>
216-
<dt><dfn data-lt="prefixes">prefix</dfn></dt><dd>
217-
A <a>prefix</a> is a <a>term</a> that expands to a vocabulary <a>base IRI</a>. It
218-
is typically used along with a <em>suffix</em> to form a <a>compact IRI</a> to create an IRI
219-
within a vocabulary.</dd>
216+
<dt><dfn data-lt="prefixes">prefix</dfn></dt><dd>
217+
A <a>prefix</a> is the first component of a <a>compact IRI</a> which comes from a
218+
<a>term</a> that maps to a string that, when prepended to the suffix of the <a>compact IRI</a>
219+
results in an <a>absolute IRI</a>.</dd>
220220
<dt><dfn>processing mode</dfn></dt><dd>
221221
The processing mode defines how a JSON-LD document is processed.
222222
By default, all documents are assumed to be conformat with
@@ -252,7 +252,7 @@ <h1>General Terminology</h1>
252252
<dt><dfn data-lt="term definitions">term definition</dfn></dt><dd>
253253
A term definition is an entry in a <a>context</a>, where the key defines a <a>term</a> which may be used within
254254
a <a>JSON object</a> as a <a>property</a>, type, or elsewhere that a string is interpreted as a vocabulary item.
255-
Its value is either a string, expanding to an absolute IRI, or an <a>expanded term definition</a>.
255+
Its value is either a string (<dfn data-lt="simple terms|simple term|simple term definitions">simple term definition</dfn>), expanding to an absolute IRI, or an <a>expanded term definition</a>.
256256
</dd>
257257
<dt class="changed"><dfn data-lt="type maps">type map</dfn></dt><dd class="changed">
258258
An <a>type map</a> is a <a>JSON object</a> value of a <a>term</a> defined with

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

+83-32
Large diffs are not rendered by default.

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,21 @@ <h3>JsonLdProcessor</h3>
12221222
<li>Set <em>context</em> to the value of <code>@context</code>
12231223
from <a data-lt="JsonLdProcessor-frame-frame">frame</a>, if it exists, or to
12241224
a new empty <a>context</a>, otherwise.</li>
1225+
<li class="changed">Initialize an <a>active context</a> using <em>context</em>;
1226+
the <a>base IRI</a> is set to
1227+
the <a data-cite="JSON-LD-API#dom-jsonldoptions-base">base</a> option from
1228+
<a data-lt="jsonldprocessor-frame-options">options</a>, if set;
1229+
otherwise, if the
1230+
<a data-cite="JSON-LD-API#dom-jsonldoptions-compacttorelative">compactToRelative</a> option is
1231+
<strong>true</strong>, to the IRI of the currently being processed
1232+
document, if available; otherwise to <code>null</code>.</li>
12251233
<li>If <a data-lt="JsonLdProcessor-frame-frame">frame</a> has a top-level
12261234
property which expands to <code>@graph</code> set the <a data-link-for="JsonLdOptions">frameDefault</a>
12271235
option to <a data-lt="JsonLdProcessor-frame-options">options</a> with the
12281236
value <code>true</code>.</li>
12291237
<li>Set <em>framed</em> to the result of using the
12301238
<a href="#framing-algorithm">Framing algorithm</a>, passing
1231-
<em>expanded input</em>, <em>expanded frame</em>, <em>context</em>, and <em>options</em>.</li>
1239+
<em>expanded input</em>, <em>expanded frame</em>, <a>active context</a>, and <em>options</em>.</li>
12321240
<li>Fulfill the <em>promise</em> passing <em>framed</em>.</li>
12331241
</ol>
12341242

spec/latest/json-ld/index.html

+37-12
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ <h2>Syntax Tokens and Keywords</h2>
404404
This keyword is described in <a class="sectionRef" href="#named-graphs"></a>.</dd>
405405
<dt class="changed"><code>@nest</code></dt><dd class="changed">Collects a set of <a>nested properties</a> within
406406
a <a>node object</a>.</dd>
407+
<dt class="changed"><code>@prefix</code></dt><dd class="changed">
408+
With the value <a>true</a>, allows this <a>term</a> to be used to construct a <a>compact IRI</a>
409+
when compacting.</dd>
407410
<dt class="changed"><code>@version</code></dt><dd class="changed">
408411
Used in a <a>context definition</a> to set the <a>processing mode</a>.
409412
New features since <a data-cite="JSON-LD-20140116">JSON-LD 1.0</a> [[!JSON-LD-20140116]] described in this specification are
@@ -1043,6 +1046,20 @@ <h2>Compact IRIs</h2>
10431046
underscore (<code>_</code>), the value is interpreted as <a>blank node identifier</a>
10441047
instead.</p>
10451048

1049+
<p class="changed">In JSON-LD 1.0, terms will be used as <a>compact IRI</a> prefixes when
1050+
compacting only if they map to a value that ends with a URI <a
1051+
data-cite="RFC3986#section-2.2">gen-delim</a> character (e.g, <code>/</code>,
1052+
<code>#</code> and others, see [[!RFC3986]]).</p>
1053+
1054+
<p class="note">This represents a small change to the 1.0 algorithm to prevent IRIs
1055+
that are not really intended to be used as prefixes from being used for creating
1056+
<a>compact IRIs</a>.</p>
1057+
1058+
<p class="changed">When <a>processing mode</a> is set to <code>json-ld-1.1</code>, terms will be used as <a>compact IRI</a> prefixes
1059+
when compacting only if their <a>expanded term definition</a> contains
1060+
a <code>@prefix</code> member with the value <a>true</a>, or if it has a
1061+
a <a>simple term definition</a> where the value ends with a URI <a data-cite="RFC3986#section-2.2">gen-delim</a> character
1062+
(e.g, <code>/</code>, <code>#</code> and others, see [[!RFC3986]]).</p>
10461063

10471064
<p>It's also possible to use compact IRIs within the context as shown in the
10481065
following example:</p>
@@ -2228,7 +2245,7 @@ <h2>Scoped Contexts</h2>
22282245
<p>Scoping on <code>@type</code> is useful when common properties are used to relate things of different types, where the vocabularies in use within different entities calls for different context scoping. For example, `hasPart`/`partOf` may be common terms used in a document, but mean different things depending on the context.</p>
22292246

22302247
<p class="note">Scoped Contexts are a new feature in JSON-LD 1.1, requiring
2231-
<a>processing mode</a> set to <code>json-ld-1.1</code></p>
2248+
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
22322249
</section>
22332250

22342251

@@ -2788,7 +2805,7 @@ <h2>Node Identifier Indexing</h2>
27882805
</pre>
27892806

27902807
<p class="note"><a>Id maps</a> are a new feature in JSON-LD 1.1, requiring
2791-
<a>processing mode</a> set to <code>json-ld-1.1</code></p>
2808+
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
27922809
</section>
27932810

27942811
<section class="informative changed">
@@ -2869,7 +2886,7 @@ <h2>Node Type Indexing</h2>
28692886
</pre>
28702887

28712888
<p class="note"><a>Type maps</a> are a new feature in JSON-LD 1.1, requiring
2872-
<a>processing mode</a> set to <code>json-ld-1.1</code></p>
2889+
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
28732890
</section>
28742891

28752892
<section class="informative changed">
@@ -2951,7 +2968,7 @@ <h2>Nested Properties</h2>
29512968
</pre>
29522969

29532970
<p class="note"><a>Nested properties</a> are a new feature in JSON-LD 1.1, requiring
2954-
<a>processing mode</a> set to <code>json-ld-1.1</code></p>
2971+
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
29552972
</section>
29562973

29572974
<section class="informative">
@@ -3682,7 +3699,8 @@ <h2>Context Definitions</h2>
36823699

36833700
<p>An <a>expanded term definition</a> MUST be a <a>JSON object</a>
36843701
composed of zero or more keys from <code>@id</code>, <code>@reverse</code>,
3685-
<code>@type</code>, <code>@language</code>, <code class="changed">@context</code> or <code>@container</code>. An
3702+
<code>@type</code>, <code>@language</code>, <code class="changed">@context</code>,
3703+
<code class="changed">@prefix</code> or <code>@container</code>. An
36863704
<a>expanded term definition</a> SHOULD NOT contain any other keys.</p>
36873705

36883706
<p>If an <a>expanded term definition</a> has an <code>@reverse</code> member,
@@ -3727,14 +3745,17 @@ <h2>Context Definitions</h2>
37273745
<p class="changed">If an <a>expanded term definition</a> has an <code>@context</code> member,
37283746
it MUST be a valid <code>context definition</code>.</p>
37293747

3748+
<p class="changed">If the <a>expanded term definition</a> contains the <code>@nest</code>
3749+
<a>keyword</a>, its value MUST be either <code>@nest</code>, or a term
3750+
which expands to <code>@nest</code>.</p>
3751+
3752+
<p class="changed">If the <a>expanded term definition</a> contains the <code>@prefix</code>
3753+
<a>keyword</a>, its value MUST be <code>true</code> or <code>false</code>.</p>
3754+
37303755
<p><a>Terms</a> MUST NOT be used in a circular manner. That is,
37313756
the definition of a term cannot depend on the definition of another term if that other
37323757
term also depends on the first term.</p>
37333758

3734-
<p>If the <a>expanded term definition</a> contains the <code>@nest</code>
3735-
<a>keyword</a>, its value MUST be either <code>@nest</code>, or a term
3736-
which expands to <code>@nest</code>.</p>
3737-
37383759
<p>See <a class="sectionRef" href="#the-context"></a> for further discussion on contexts.</p>
37393760
</section>
37403761

@@ -3937,17 +3958,21 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
39373958
keyword along with <code>@set</code> (other than <code>@list</code>).
39383959
This allows a way to ensure that such property values will always
39393960
be expressed in <a>array</a> form.</li>
3961+
<li>In JSON-LD 1.1, terms will be used as <a>compact IRI</a> prefixes
3962+
when compacting only if
3963+
a <a>simple term definition</a> is used where the value ends with a URI <a data-cite="RFC3986#section-2.2">gen-delim</a> character,
3964+
or if their <a>expanded term definition</a> contains
3965+
a <code>@prefix</code> member with the value <a>true</a>. The 1.0 algorithm has
3966+
been updated to only consider terms that map to a value that ends with a URI
3967+
<a data-cite="RFC3986#section-2.2">gen-delim</a> character.</li>
39403968
</ul>
39413969
</section>
39423970

39433971
<section class="appendix informative">
39443972
<h4>Open Issues</h4>
39453973
<p>The following is a list of open issues being worked on for the next release.</p>
39463974
<p class="issue" data-number="195"></p>
3947-
<p class="issue" data-number="269"></p>
39483975
<p class="issue" data-number="333"></p>
3949-
<p class="issue" data-number="407"></p>
3950-
<p class="issue" data-number="429"></p>
39513976
<p class="issue" data-number="481"></p>
39523977
</section>
39533978

test-suite/context.jsonld

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"description": "rdfs:comment",
2121
"base": { "@type": "@id" },
2222
"compactArrays": { "@type": "xsd:boolean" },
23+
"compactToRelative": { "@type": "xsd:boolean" },
2324
"documentLoader": { "@type": "xsd:string" },
2425
"expandContext": { "@type": "xsd:string" },
2526
"processingMode": { "@type": "xsd:string" },

test-suite/tests/compact-0038-out.jsonld

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
"title": {
2121
"en": {
2222
"@type": "site-cd:field-types/title_field",
23-
"title:/value": "This is the English title"
23+
"site-cd:node/article/title/value": "This is the English title"
2424
},
2525
"es": {
2626
"@type": "site-cd:field-types/title_field",
27-
"title:/value": "Este es el t’tulo espa–ol"
27+
"site-cd:node/article/title/value": "Este es el t’tulo espa–ol"
2828
}
2929
},
3030
"body": {
3131
"en": {
3232
"@type": "site-cd:field-types/text_with_summary",
33-
"body:/value": "This is the English body. There is no Spanish body, so this will be displayed for both the English and Spanish versions.",
34-
"body:/summary": "This is the teaser for the body.",
35-
"body:/format": "full_html"
33+
"site-cd:node/article/body/value": "This is the English body. There is no Spanish body, so this will be displayed for both the English and Spanish versions.",
34+
"site-cd:node/article/body/summary": "This is the teaser for the body.",
35+
"site-cd:node/article/body/format": "full_html"
3636
}
3737
},
3838
"field_tags": {

test-suite/tests/compact-0045-context.jsonld

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"@context": {
33
"term": "http://example.com/terms-are-not-considered-in-id",
4-
"compact-iris": "http://example.com/compact-iris-",
4+
"compact-iris": "http://example.com/compact-iris#",
55
"property": "http://example.com/property",
66
"@vocab": "http://example.org/vocab-is-not-considered-for-id"
77
},

test-suite/tests/compact-0045-in.jsonld

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"@id": "http://json-ld.org/test-suite/tests/term",
44
"http://example.com/property": [
55
{
6-
"@id": "http://example.com/compact-iris-are-considered",
6+
"@id": "http://example.com/compact-iris#are-considered",
77
"http://example.com/property": [
88
{ "@value": "@id supports the following values: relative, absolute, and compact IRIs" }
99
]

test-suite/tests/compact-0045-out.jsonld

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"@context": {
33
"term": "http://example.com/terms-are-not-considered-in-id",
4-
"compact-iris": "http://example.com/compact-iris-",
4+
"compact-iris": "http://example.com/compact-iris#",
55
"property": "http://example.com/property",
66
"@vocab": "http://example.org/vocab-is-not-considered-for-id"
77
},

test-suite/tests/compact-manifest.jsonld

+82-1
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,87 @@
844844
"context": "compact-n010-context.jsonld",
845845
"expect": "compact-n010-out.jsonld",
846846
"option": {"processingMode": "json-ld-1.1"}
847+
}, {
848+
"@id": "#tp001",
849+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
850+
"name": "Compact IRI does may use an expanded term definition in 1.0",
851+
"purpose": "Terms with an expanded term definition may be used for creating compact IRIs",
852+
"option": {"processingMode": "json-ld-1.0"},
853+
"input": "compact-p001-in.jsonld",
854+
"context": "compact-p001-context.jsonld",
855+
"expect": "compact-p001-out.jsonld"
856+
}, {
857+
"@id": "#tp002",
858+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
859+
"name": "Compact IRI does not use expanded term definition in 1.1",
860+
"purpose": "Terms with an expanded term definition are not used for creating compact IRIs",
861+
"option": {"processingMode": "json-ld-1.1"},
862+
"input": "compact-p002-in.jsonld",
863+
"context": "compact-p002-context.jsonld",
864+
"expect": "compact-p002-out.jsonld"
865+
}, {
866+
"@id": "#tp003",
867+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
868+
"name": "Compact IRI does not use simple term that does not end with a gen-delim",
869+
"purpose": "Terms not ending with a gen-delim are not used for creating compact IRIs",
870+
"input": "compact-p003-in.jsonld",
871+
"context": "compact-p003-context.jsonld",
872+
"expect": "compact-p003-out.jsonld"
873+
}, {
874+
"@id": "#tp004",
875+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
876+
"name": "Compact IRIs using simple terms ending with gen-delim",
877+
"purpose": "All simple terms ending with gen-delim are suitable for compaction",
878+
"input": "compact-p004-in.jsonld",
879+
"context": "compact-p004-context.jsonld",
880+
"expect": "compact-p004-out.jsonld"
881+
}, {
882+
"@id": "#tp005",
883+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
884+
"name": "Compact IRI uses term with definition including @prefix: true",
885+
"purpose": "Expanded term definition may set prefix explicitly in 1.1",
886+
"option": {"processingMode": "json-ld-1.1"},
887+
"input": "compact-p005-in.jsonld",
888+
"context": "compact-p005-context.jsonld",
889+
"expect": "compact-p005-out.jsonld"
890+
}, {
891+
"@id": "#tp006",
892+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
893+
"name": "Compact IRI uses term with definition including @prefix: true",
894+
"purpose": "Expanded term definition may set prefix explicitly in 1.1",
895+
"option": {"processingMode": "json-ld-1.1"},
896+
"input": "compact-p006-in.jsonld",
897+
"context": "compact-p006-context.jsonld",
898+
"expect": "compact-p006-out.jsonld"
899+
}, {
900+
"@id": "#tp007",
901+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
902+
"name": "Compact IRI not used as prefix",
903+
"purpose": "Terms including a colon are excluded from being used as a prefix",
904+
"input": "compact-p007-in.jsonld",
905+
"context": "compact-p007-context.jsonld",
906+
"expect": "compact-p007-out.jsonld"
907+
}, {
908+
"@id": "#tr001",
909+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
910+
"name": "Expands and compacts to document base by default",
911+
"purpose": "Compact IRI attempts to compact document-relative IRIs",
912+
"input": "compact-r001-in.jsonld",
913+
"context": "compact-r001-context.jsonld",
914+
"expect": "compact-r001-out.jsonld",
915+
"option": {"base": "http://example.org/", "processingMode": "json-ld-1.1"}
916+
}, {
917+
"@id": "#tr002",
918+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
919+
"name": "Expands and does not compact to document base with compactToRelative false",
920+
"purpose": "With compactToRelative option set to false, IRIs which could be made relative to the document base are not made relative.",
921+
"input": "compact-r002-in.jsonld",
922+
"context": "compact-r002-context.jsonld",
923+
"expect": "compact-r002-out.jsonld",
924+
"option": {
925+
"processingMode": "json-ld-1.1",
926+
"compactToRelative": false
927+
}
847928
}, {
848929
"@id": "#ts001",
849930
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
@@ -854,7 +935,7 @@
854935
"expect": "compact-s001-out.jsonld",
855936
"option": {"processingMode": "json-ld-1.1"}
856937
}, {
857-
"@id": "#ts001",
938+
"@id": "#ts002",
858939
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
859940
"name": "@context with array including @set uses array values",
860941
"purpose": "@context values may include @set along with another compatible value",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@context": {
3+
"ex": {"@id": "http://example.org/"}
4+
}
5+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@id": "http://example.org/id1",
3+
"@type": ["http://example.org/Type1", "http://example.org/Type2"],
4+
"http://example.org/term": {"@id": "http://example.org/id2"}
5+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"ex": {"@id": "http://example.org/"}
4+
},
5+
"@id": "ex:id1",
6+
"@type": ["ex:Type1", "ex:Type2"],
7+
"ex:term": {"@id": "ex:id2"}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@context": {
3+
"ex": {"@id": "http://example.org/"}
4+
}
5+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@id": "http://example.org/id1",
3+
"@type": ["http://example.org/Type1", "http://example.org/Type2"],
4+
"http://example.org/term": {"@id": "http://example.org/id2"}
5+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"ex": {"@id": "http://example.org/"}
4+
},
5+
"@id": "http://example.org/id1",
6+
"@type": ["http://example.org/Type1", "http://example.org/Type2"],
7+
"http://example.org/term": {"@id": "http://example.org/id2"}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"compact-iris:": "http://example.com/compact-iris-",
4+
"property": "http://example.com/property"
5+
}
6+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"http://example.com/property": {
3+
"@id": "http://example.com/compact-iris-are-considered",
4+
"http://example.com/property": "Prefix terms must end in a gen-delim"
5+
}
6+
}

0 commit comments

Comments
 (0)