Skip to content

Commit 5b2d8e9

Browse files
committed
Add text with ABNF for recognizing, warning and ignoring keyword-like strings and add expansion tests.
1 parent d98d011 commit 5b2d8e9

11 files changed

+169
-16
lines changed

index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,8 @@ <h3>Algorithm</h3>
14581458
<var>term</var> MUST NOT be a <a>keyword</a> and a
14591459
<a data-link-for="JsonLdErrorCode">keyword redefinition</a>
14601460
error has been detected and processing is aborted.
1461-
If <var>term</var> has the form of a keyword (i.e., it begins with `"@"`),
1461+
If <var>term</var> has the form of a keyword
1462+
(i.e., it matches the ABNF rule `"@"1*ALPHA` from [[RFC5234]]),
14621463
return; processors SHOULD generate a warning.</li>
14631464
<li class="changed">Set <var>previous definition</var> to any existing
14641465
<a>term definition</a> for <var>term</var> in <var>active context</var>,
@@ -1516,7 +1517,8 @@ <h3>Algorithm</h3>
15161517
<a data-link-for="JsonLdErrorCode">invalid IRI mapping</a>
15171518
error has been detected and processing is aborted.</li>
15181519
<li>If the value associated with the `@reverse` <a>entry</a> is a string
1519-
having the form of a keyword (i.e., it begins with `"@"`),
1520+
having the form of a keyword
1521+
(i.e., it matches the ABNF rule `"@"1*ALPHA` from [[RFC5234]]),
15201522
return; processors SHOULD generate a warning.</li>
15211523
<li>Otherwise, set the <a>IRI mapping</a> of <var>definition</var> to the
15221524
result of using the <a href="#iri-expansion">IRI Expansion algorithm</a>,
@@ -1557,7 +1559,8 @@ <h3>Algorithm</h3>
15571559
error has been detected and processing is aborted.</li>
15581560
<li>If the value associated with the `@id` <a>entry</a>
15591561
is not a <a>keyword</a>, but
1560-
has the form of a <a>keyword</a> (i.e., it begins with `"@"`),
1562+
has the form of a <a>keyword</a>
1563+
(i.e., it matches the ABNF rule `"@"1*ALPHA` from [[RFC5234]]),
15611564
return; processors SHOULD generate a warning.</li>
15621565
<li>Otherwise, set the <a>IRI mapping</a> of <var>definition</var> to the
15631566
result of using the <a href="#iri-expansion">IRI Expansion algorithm</a>, passing
@@ -3004,7 +3007,8 @@ <h3>Algorithm</h3>
30043007
<li>If <var>value</var> is a <a>keyword</a> or <code>null</code>,
30053008
return <var>value</var> as is.</li>
30063009
<li class="changed">
3007-
If <var>value</var> has the form of a keyword (i.e., it begins with `"@"`),
3010+
If <var>value</var> has the form of a keyword
3011+
(i.e., it matches the ABNF rule `"@"1*ALPHA` from [[RFC5234]]),
30083012
a processor SHOULD generate a warning and return `null`.</li>
30093013
<li>If <var>local context</var> is not <code>null</code>, it contains
30103014
an <a>entry</a> with a key that equals <var>value</var>, and the value of the <a>entry</a>

tests/expand-manifest.html

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,24 +2820,24 @@ <h2>
28202820
</dd>
28212821
</dl>
28222822
</dd>
2823-
<dt id='t0117'>
2824-
Test t0117 A term starting with a colon can expand to a different IRI
2823+
<dt id='t0119'>
2824+
Test t0119 Ignore some terms with @, allow others.
28252825
</dt>
28262826
<dd>
28272827
<dl class='entry'>
28282828
<dt>id</dt>
2829-
<dd>#t0117</dd>
2829+
<dd>#t0119</dd>
28302830
<dt>Type</dt>
28312831
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
28322832
<dt>Purpose</dt>
2833-
<dd>Terms may begin with a colon and not be treated as IRIs.</dd>
2833+
<dd>Processors SHOULD generate a warning and MUST ignore terms having the form of a keyword.</dd>
28342834
<dt>input</dt>
28352835
<dd>
2836-
<a href='expand/0117-in.jsonld'>expand/0117-in.jsonld</a>
2836+
<a href='expand/0119-in.jsonld'>expand/0119-in.jsonld</a>
28372837
</dd>
28382838
<dt>expect</dt>
28392839
<dd>
2840-
<a href='expand/0117-out.jsonld'>expand/0117-out.jsonld</a>
2840+
<a href='expand/0119-out.jsonld'>expand/0119-out.jsonld</a>
28412841
</dd>
28422842
<dt>Options</dt>
28432843
<dd>
@@ -2848,24 +2848,80 @@ <h2>
28482848
</dd>
28492849
</dl>
28502850
</dd>
2851-
<dt id='t0118'>
2852-
Test t0118 Expanding a value staring with a colon does not treat that value as an IRI
2851+
<dt id='t0120'>
2852+
Test t0120 Ignore some values of @id with @, allow others.
28532853
</dt>
28542854
<dd>
28552855
<dl class='entry'>
28562856
<dt>id</dt>
2857-
<dd>#t0118</dd>
2857+
<dd>#t0120</dd>
28582858
<dt>Type</dt>
28592859
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
28602860
<dt>Purpose</dt>
2861-
<dd>Terms may begin with a colon and not be treated as IRIs.</dd>
2861+
<dd>Processors SHOULD generate a warning and MUST ignore values of @id having the form of a keyword.</dd>
28622862
<dt>input</dt>
28632863
<dd>
2864-
<a href='expand/0118-in.jsonld'>expand/0118-in.jsonld</a>
2864+
<a href='expand/0120-in.jsonld'>expand/0120-in.jsonld</a>
28652865
</dd>
28662866
<dt>expect</dt>
28672867
<dd>
2868-
<a href='expand/0118-out.jsonld'>expand/0118-out.jsonld</a>
2868+
<a href='expand/0120-out.jsonld'>expand/0120-out.jsonld</a>
2869+
</dd>
2870+
<dt>Options</dt>
2871+
<dd>
2872+
<dl class='options'>
2873+
<dt>specVersion</dt>
2874+
<dd>json-ld-1.1</dd>
2875+
</dl>
2876+
</dd>
2877+
</dl>
2878+
</dd>
2879+
<dt id='t0121'>
2880+
Test t0121 Ignore some values of @reverse with @, allow others.
2881+
</dt>
2882+
<dd>
2883+
<dl class='entry'>
2884+
<dt>id</dt>
2885+
<dd>#t0121</dd>
2886+
<dt>Type</dt>
2887+
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
2888+
<dt>Purpose</dt>
2889+
<dd>Processors SHOULD generate a warning and MUST ignore values of @reverse having the form of a keyword.</dd>
2890+
<dt>input</dt>
2891+
<dd>
2892+
<a href='expand/0121-in.jsonld'>expand/0121-in.jsonld</a>
2893+
</dd>
2894+
<dt>expect</dt>
2895+
<dd>
2896+
<a href='expand/0121-out.jsonld'>expand/0121-out.jsonld</a>
2897+
</dd>
2898+
<dt>Options</dt>
2899+
<dd>
2900+
<dl class='options'>
2901+
<dt>specVersion</dt>
2902+
<dd>json-ld-1.1</dd>
2903+
</dl>
2904+
</dd>
2905+
</dl>
2906+
</dd>
2907+
<dt id='t0122'>
2908+
Test t0122 Ignore some IRIs when that start with @ when expanding.
2909+
</dt>
2910+
<dd>
2911+
<dl class='entry'>
2912+
<dt>id</dt>
2913+
<dd>#t0122</dd>
2914+
<dt>Type</dt>
2915+
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
2916+
<dt>Purpose</dt>
2917+
<dd>Processors SHOULD generate a warning and MUST ignore IRIs having the form of a keyword.</dd>
2918+
<dt>input</dt>
2919+
<dd>
2920+
<a href='expand/0122-in.jsonld'>expand/0122-in.jsonld</a>
2921+
</dd>
2922+
<dt>expect</dt>
2923+
<dd>
2924+
<a href='expand/0122-out.jsonld'>expand/0122-out.jsonld</a>
28692925
</dd>
28702926
<dt>Options</dt>
28712927
<dd>

tests/expand-manifest.jsonld

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,38 @@
884884
"input": "expand/0118-in.jsonld",
885885
"expect": "expand/0118-out.jsonld",
886886
"option": {"specVersion": "json-ld-1.1"}
887+
}, {
888+
"@id": "#t0119",
889+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
890+
"name": "Ignore some terms with @, allow others.",
891+
"purpose": "Processors SHOULD generate a warning and MUST ignore terms having the form of a keyword.",
892+
"input": "expand/0119-in.jsonld",
893+
"expect": "expand/0119-out.jsonld",
894+
"option": {"specVersion": "json-ld-1.1"}
895+
}, {
896+
"@id": "#t0120",
897+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
898+
"name": "Ignore some values of @id with @, allow others.",
899+
"purpose": "Processors SHOULD generate a warning and MUST ignore values of @id having the form of a keyword.",
900+
"input": "expand/0120-in.jsonld",
901+
"expect": "expand/0120-out.jsonld",
902+
"option": {"specVersion": "json-ld-1.1"}
903+
}, {
904+
"@id": "#t0121",
905+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
906+
"name": "Ignore some values of @reverse with @, allow others.",
907+
"purpose": "Processors SHOULD generate a warning and MUST ignore values of @reverse having the form of a keyword.",
908+
"input": "expand/0121-in.jsonld",
909+
"expect": "expand/0121-out.jsonld",
910+
"option": {"specVersion": "json-ld-1.1"}
911+
}, {
912+
"@id": "#t0122",
913+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
914+
"name": "Ignore some IRIs when that start with @ when expanding.",
915+
"purpose": "Processors SHOULD generate a warning and MUST ignore IRIs having the form of a keyword.",
916+
"input": "expand/0122-in.jsonld",
917+
"expect": "expand/0122-out.jsonld",
918+
"option": {"specVersion": "json-ld-1.1"}
887919
}, {
888920
"@id": "#tc001",
889921
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],

tests/expand/0119-in.jsonld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@": "http://example.org/vocab/at",
4+
"@foo.bar": "http://example.org/vocab/foo.bar",
5+
"@ignoreMe": "http://example.org/vocab/ignoreMe"
6+
},
7+
"@": "allowed",
8+
"@foo.bar": "allowed",
9+
"@ignoreMe": "ignored"
10+
}

tests/expand/0119-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[{
2+
"http://example.org/vocab/at": [{"@value": "allowed"}],
3+
"http://example.org/vocab/foo.bar": [{"@value": "allowed"}]
4+
}]

tests/expand/0120-in.jsonld

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example.orb/vocab/",
4+
"at": {"@id": "@"},
5+
"foo.bar": {"@id": "@foo.bar"},
6+
"ignoreMe": {"@id": "@ignoreMe"}
7+
},
8+
"at": "allowed",
9+
"foo.bar": "allowed",
10+
"ignoreMe": "resolves to @vocab"
11+
}

tests/expand/0120-out.jsonld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[{
2+
"http://example.orb/vocab/@": [{"@value": "allowed"}],
3+
"http://example.orb/vocab/@foo.bar": [{"@value": "allowed"}],
4+
"http://example.orb/vocab/ignoreMe": [{"@value": "resolves to @vocab"}]
5+
}]

tests/expand/0121-in.jsonld

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": {
3+
"@base": "http://example.org/",
4+
"@vocab": "http://example.org/vocab/",
5+
"at": {"@reverse": "@"},
6+
"foo.bar": {"@reverse": "@foo.bar"}
7+
},
8+
"@id": "foo",
9+
"at": {"@id": "allowed"},
10+
"foo.bar": {"@id": "allowed"}
11+
}

tests/expand/0121-out.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[{
2+
"@id": "http://example.org/foo",
3+
"@reverse": {
4+
"http://example.org/vocab/@": [{"@id": "http://example.org/allowed"}],
5+
"http://example.org/vocab/@foo.bar": [{"@id": "http://example.org/allowed"}]
6+
}
7+
}]

tests/expand/0122-in.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"@base": "http://example.org/"
4+
},
5+
"http://example.org/vocab/at": {"@id": "@"},
6+
"http://example.org/vocab/foo.bar": {"@id": "@foo.bar"},
7+
"http://example.org/vocab/ignoreme": {"@id": "@ignoreMe"}
8+
}

tests/expand/0122-out.jsonld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[{
2+
"http://example.org/vocab/at": [{"@id": "http://example.org/@"}],
3+
"http://example.org/vocab/foo.bar": [{"@id": "http://example.org/@foo.bar"}],
4+
"http://example.org/vocab/ignoreme": [{"@id": ""}]
5+
}]

0 commit comments

Comments
 (0)