Skip to content

Update to make terms that have the form of a keyword errors. #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1505,12 +1505,12 @@ <h3>Algorithm</h3>
<a data-link-for="JsonLdErrorCode">keyword redefinition</a> error has
been detected and processing is aborted.</li>
<li><span class="changed">Otherwise</span>, since <a>keywords</a> cannot be overridden,
<var>term</var> MUST NOT be a <a>keyword</a> and a
<var>term</var> MUST NOT be a <a>keyword</a>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually "MUST NOT have the form of a keyword" would be enough,
since all actual keywords also have the form of a keyword.
But it might be better to be explicit about the fact that we reject both actual keywords and would-be keywords.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my thinking. An implementation can always choose to do this optimization.

or have the form of a <a>keyword</a>
(i.e., match the ABNF rule `"@"1*ALPHA` from [[RFC5234]]),
and a
<a data-link-for="JsonLdErrorCode">keyword redefinition</a>
error has been detected and processing is aborted.
If <var>term</var> has the form of a keyword
(i.e., it matches the ABNF rule `"@"1*ALPHA` from [[RFC5234]]),
return; processors SHOULD generate a warning.</li>
error has been detected and processing is aborted.</li>
<li class="changed">Initialize <var>previous definition</var> to any existing
<a>term definition</a> for <var>term</var> in <var>active context</var>,
removing that <a>term definition</a> from <var>active context</var>.</li>
Expand Down Expand Up @@ -6867,7 +6867,8 @@ <h4>JsonLdErrorCode</h4>
<li>The <a>processing mode</a> is now implicitly `json-ld-1.1`, unless set
explicitly to `json-ld-1.0`.</li>
<li>Improve notation using <a>IRI</a>, <a>IRI reference</a>, and <a>relative IRI reference</a>.</li>
<li>Ignore terms and IRIs that have the form of a keyword (`"@"1*ALPHA`).</li>
<li>Ignore IRIs that have the form of a keyword (`"@"1*ALPHA`).</li>
<li>Error on terms that have the form of a keyword (`"@"1*ALPHA`).</li>
</ul>
</section>

Expand Down
55 changes: 45 additions & 10 deletions tests/expand-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ <h2>
<dd>
<a href='expand/0005-out.jsonld'>expand/0005-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.0</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='t0006'>
Expand Down Expand Up @@ -2877,7 +2884,7 @@ <h2>
</dl>
</dd>
<dt id='t0119'>
Test t0119 Ignore some terms with @, allow others.
Test t0119 Allow some terms with @.
</dt>
<dd>
<dl class='entry'>
Expand Down Expand Up @@ -4482,7 +4489,7 @@ <h2>
</dl>
</dd>
<dt id='te019'>
Test te019 Invalid keyword alias
Test te019 Invalid keyword alias (@context)
</dt>
<dd>
<dl class='entry'>
Expand Down Expand Up @@ -5206,6 +5213,34 @@ <h2>
</dd>
</dl>
</dd>
<dt id='te051'>
Test te051 Error if terms that aren't, but look like keywords are used.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#te051</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Terms MUST NOT have the form of a keyword.</dd>
<dt>input</dt>
<dd>
<a href='expand/e051-in.jsonld'>expand/e051-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
keyword redefinition
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tec01'>
Test tec01 Invalid keyword in term definition
</dt>
Expand Down Expand Up @@ -8547,23 +8582,23 @@ <h2>
</dl>
</dd>
<dt id='tpr34'>
Test tpr34 Ignores a non-keyword term starting with '@'
Test tpr34 Errors on a non-keyword term starting with '@'
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr34</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dd>Terms in the form of a keyword, which are not keywords, are errors.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr34-in.jsonld'>expand/pr34-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='expand/pr34-out.jsonld'>expand/pr34-out.jsonld</a>
keyword redefinition
</dd>
<dt>Options</dt>
<dd>
Expand All @@ -8575,23 +8610,23 @@ <h2>
</dl>
</dd>
<dt id='tpr35'>
Test tpr35 Ignores a non-keyword term starting with '@' (with @vocab)
Test tpr35 Errors on a non-keyword term starting with '@' (with @vocab)
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr35</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dd>Terms in the form of a keyword, which are not keywords, are errors.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr35-in.jsonld'>expand/pr35-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='expand/pr35-out.jsonld'>expand/pr35-out.jsonld</a>
keyword redefinition
</dd>
<dt>Options</dt>
<dd>
Expand Down
30 changes: 16 additions & 14 deletions tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"name": "do not expand aliased @id/@type",
"purpose": "If a keyword is aliased, it is not used when expanding",
"input": "expand/0005-in.jsonld",
"expect": "expand/0005-out.jsonld"
"expect": "expand/0005-out.jsonld",
"option": {"specVersion": "json-ld-1.0"}
}, {
"@id": "#t0006",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
Expand Down Expand Up @@ -887,7 +888,7 @@
}, {
"@id": "#t0119",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Ignore some terms with @, allow others.",
"name": "Allow some terms with @.",
"purpose": "Processors SHOULD generate a warning and MUST ignore terms having the form of a keyword.",
"input": "expand/0119-in.jsonld",
"expect": "expand/0119-out.jsonld",
Expand Down Expand Up @@ -1586,11 +1587,12 @@
"expectErrorCode": "invalid IRI mapping"
}, {
"@id": "#te051",
"@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ],
"name": "Invalid keyword alias (@base)",
"purpose": "Verifies that an exception is raised on expansion when a invalid keyword alias is found",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Error if terms that aren't, but look like keywords are used.",
"purpose": "Terms MUST NOT have the form of a keyword.",
"input": "expand/e051-in.jsonld",
"expectErrorCode": "invalid keyword alias"
"expectErrorCode": "keyword redefinition",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tec01",
"@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ],
Expand Down Expand Up @@ -2545,20 +2547,20 @@
"expectErrorCode": "invalid term definition"
}, {
"@id": "#tpr34",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Ignores a non-keyword term starting with '@'",
"purpose": "Terms in the form of a keyword, which are not keywords, are ignored.",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Errors on a non-keyword term starting with '@'",
"purpose": "Terms in the form of a keyword, which are not keywords, are errors.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr34-in.jsonld",
"expect": "expand/pr34-out.jsonld"
"expectErrorCode": "keyword redefinition"
}, {
"@id": "#tpr35",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Ignores a non-keyword term starting with '@' (with @vocab)",
"purpose": "Terms in the form of a keyword, which are not keywords, are ignored.",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Errors on a non-keyword term starting with '@' (with @vocab)",
"purpose": "Terms in the form of a keyword, which are not keywords, are errors.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr35-in.jsonld",
"expect": "expand/pr35-out.jsonld"
"expectErrorCode": "keyword redefinition"
}, {
"@id": "#tpr36",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
Expand Down
3 changes: 1 addition & 2 deletions tests/expand/0119-in.jsonld
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"@context": {
"@": "http://example.org/vocab/at",
"@foo.bar": "http://example.org/vocab/foo.bar",
"@ignoreMe": "http://example.org/vocab/ignoreMe"
"@foo.bar": "http://example.org/vocab/foo.bar"
},
"@": "allowed",
"@foo.bar": "allowed",
Expand Down
6 changes: 6 additions & 0 deletions tests/expand/e051-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@iri": "http://example/cant-be-used-as-a-term"
},
"@iri": "http://example.org/iri"
}
3 changes: 0 additions & 3 deletions tests/expand/pr34-out.jsonld

This file was deleted.

3 changes: 0 additions & 3 deletions tests/expand/pr35-out.jsonld

This file was deleted.

7 changes: 7 additions & 0 deletions tests/flatten-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ <h2>
<dd>
<a href='flatten/0005-out.jsonld'>flatten/0005-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.0</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='t0006'>
Expand Down
3 changes: 2 additions & 1 deletion tests/flatten-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"name": "do not expand aliased @id/@type",
"purpose": "If a keyword is aliased, it is not used when flattening",
"input": "flatten/0005-in.jsonld",
"expect": "flatten/0005-out.jsonld"
"expect": "flatten/0005-out.jsonld",
"option": {"specVersion": "json-ld-1.0"}
}, {
"@id": "#t0006",
"@type": ["jld:PositiveEvaluationTest", "jld:FlattenTest"],
Expand Down
42 changes: 28 additions & 14 deletions tests/toRdf-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,13 @@ <h2>
<dd>
<a href='toRdf/e005-out.nq'>toRdf/e005-out.nq</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.0</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='te006'>
Expand Down Expand Up @@ -2693,23 +2700,30 @@ <h2>
</dl>
</dd>
<dt id='te051'>
Test te051 Expansion of keyword aliases in term definitions
Test te051 Error if terms that aren't, but look like keywords are used.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#te051</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
<dd>jld:NegativeEvaluationTest, jld:ToRDFTest</dd>
<dt>Purpose</dt>
<dd>RDF version of expand-0051</dd>
<dd>Terms MUST NOT have the form of a keyword.</dd>
<dt>input</dt>
<dd>
<a href='toRdf/e051-in.jsonld'>toRdf/e051-in.jsonld</a>
<a href='expand/e051-in.jsonld'>expand/e051-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='toRdf/e051-out.nq'>toRdf/e051-out.nq</a>
keyword redefinition
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
Expand Down Expand Up @@ -4410,7 +4424,7 @@ <h2>
</dl>
</dd>
<dt id='te119'>
Test te119 Ignore some terms with @, allow others.
Test te119 Allow some terms with @.
</dt>
<dd>
<dl class='entry'>
Expand Down Expand Up @@ -7606,23 +7620,23 @@ <h2>
</dl>
</dd>
<dt id='tpr34'>
Test tpr34 Ignores a non-keyword term starting with '@'
Test tpr34 Errors on a non-keyword term starting with '@'
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr34</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
<dd>jld:NegativeEvaluationTest, jld:ToRDFTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dd>Terms in the form of a keyword, which are not keywords, are errors.</dd>
<dt>input</dt>
<dd>
<a href='toRdf/pr34-in.jsonld'>toRdf/pr34-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='toRdf/pr34-out.nq'>toRdf/pr34-out.nq</a>
keyword redefinition
</dd>
<dt>Options</dt>
<dd>
Expand All @@ -7634,23 +7648,23 @@ <h2>
</dl>
</dd>
<dt id='tpr35'>
Test tpr35 Ignores a non-keyword term starting with '@' (with @vocab)
Test tpr35 Errors on a non-keyword term starting with '@' (with @vocab)
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr35</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
<dd>jld:NegativeEvaluationTest, jld:ToRDFTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dd>Terms in the form of a keyword, which are not keywords, are errors.</dd>
<dt>input</dt>
<dd>
<a href='toRdf/pr35-in.jsonld'>toRdf/pr35-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='toRdf/pr35-out.nq'>toRdf/pr35-out.nq</a>
keyword redefinition
</dd>
<dt>Options</dt>
<dd>
Expand Down
Loading