Skip to content

Prevent keyword alias to be declared as prefix #154

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

Merged
merged 9 commits into from
Sep 30, 2019
23 changes: 22 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,9 @@ <h3>Algorithm</h3>
<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
<a data-link-for="JsonLdErrorCode">keyword redefinition</a>
error has been detected and processing is aborted.</li>
error has been detected and processing is aborted.
If <var>term</var> has the form of a keyword (i.e., it begins with `"@"`),
processing is aborted and a processor SHOULD generate a warning.</li>
<li class="changed">Set <var>previous definition</var> to any existing
<a>term definition</a> for <var>term</var> in <var>active context</var>.</li>
<li>Otherwise, remove any <var>previous definition</var> from
Expand Down Expand Up @@ -1421,6 +1423,9 @@ <h3>Algorithm</h3>
is not a <a>string</a>, an
<a data-link-for="JsonLdErrorCode">invalid IRI mapping</a>
error has been detected and processing is aborted.</li>
<li>If the value associated with the `@reverse` <a>entry</a> is a string
having the form of a keyword (i.e., it begins with `"@"`),
processing is aborted and processors SHOULD generate a warning.</li>
<li>Otherwise, set the <a>IRI mapping</a> of <var>definition</var> to the
result of using the <a href="#iri-expansion">IRI Expansion algorithm</a>,
passing <var>active context</var>, the value associated with
Expand Down Expand Up @@ -1457,6 +1462,10 @@ <h3>Algorithm</h3>
<li>Otherwise, if the value associated with the <code>@id</code> <a>entry</a> is not a <a>string</a>, an
<a data-link-for="JsonLdErrorCode">invalid IRI mapping</a>
error has been detected and processing is aborted.</li>
<li>If the value associated with the `@id` <a>entry</a> is a string
is not a <a>keyword</a>, but
havs the form of a <a>keyword</a> (i.e., it begins with `"@"`),
processing is aborted and processors SHOULD generate a warning.</li>
<li>Otherwise, set the <a>IRI mapping</a> of <var>definition</var> to the
result of using the <a href="#iri-expansion">IRI Expansion algorithm</a>, passing
<var>active context</var>, the value associated with the <code>@id</code> <a>entry</a> for
Expand Down Expand Up @@ -1618,6 +1627,10 @@ <h3>Algorithm</h3>
<code>@prefix</code> <a>entry</a>, which MUST be a <a>boolean</a>. Otherwise, an
<a data-link-for="JsonLdErrorCode">invalid @prefix value</a>
error has been detected and processing is aborted.</li>
<li>If the <a>prefix flag</a> of <var>definition</var>is set to <code>true</code>,
and its <a>IRI mapping</a> is a <a>keyword</a>,
an <a data-link-for="JsonLdErrorCode">invalid term definition</a>
has been detected and processing is aborted.</li>
</ol>
Copy link
Member

Choose a reason for hiding this comment

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

Might want to say "has the form of a keyword", so that @the-next-keyword would be rejected too. This is related to another discussion from the F2F, for which we don't yet have an open issue: we want to discourage the use of things that may be keywords in the future (should => must).

Copy link
Member

Choose a reason for hiding this comment

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

Per w3c/json-ld-syntax#16, keyword-like strings MUST be ignored and SHOULD result in a processor warning. I'll add text and tests to ensure they're ignored (with and without @vocab), but we can't test for warnings.

</li>
<li>If the value contains any <a>entry</a> other than <code>@id</code>,
Expand Down Expand Up @@ -1687,6 +1700,11 @@ <h3>Overview</h3>
in the process of being defined. We create a
<a>term definition</a> by using the
<a href="#create-term-definition">Create Term Definition algorithm</a>.</p>

<p class="changed note">Values that have the form of a keyword,
but are not keywords (i.e., they begin with `"@"`) do not
map to any value, as they are reserved for future use.
The algorithm returns `null`, so that they will be ignored when encountered.</p>
</section>

<section class="algorithm">
Expand All @@ -1708,6 +1726,9 @@ <h3>Algorithm</h3>
<ol>
<li>If <var>value</var> is a <a>keyword</a> or <code>null</code>,
return <var>value</var> as is.</li>
<li class="changed">
If <var>value</var> has the form of a keyword (i.e., it begins with `"@"`),
a processor SHOULD generate a warning and return `null`.</li>
<li>If <a>local context</a> is not <code>null</code>, it contains
an <a>entry</a> with a key that equals <var>value</var>, and the value of the <a>entry</a>
for <var>value</var> in <var>defined</var> is not <code>true</code>,
Expand Down
284 changes: 284 additions & 0 deletions tests/expand-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,15 @@ <h2>
<dd>
<a href='expand/0092-out.jsonld'>expand/0092-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='t0093'>
Expand Down Expand Up @@ -2689,6 +2698,15 @@ <h2>
<dd>
<a href='expand/0110-out.jsonld'>expand/0110-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>processingMode</dt>
<dd>json-ld-1.1</dd>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='t0111'>
Expand All @@ -2710,6 +2728,13 @@ <h2>
<dd>
<a href='expand/0111-out.jsonld'>expand/0111-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='t0112'>
Expand All @@ -2731,6 +2756,13 @@ <h2>
<dd>
<a href='expand/0112-out.jsonld'>expand/0112-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='t0113'>
Expand Down Expand Up @@ -2782,6 +2814,62 @@ <h2>
</dd>
</dl>
</dd>
<dt id='t0115'>
Test t0115 Verifies that relative IRIs as properties with @vocab: '' in 1.0 generate an error
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#t0115</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Relative property IRIs with relative @vocab in 1.0</dd>
<dt>input</dt>
<dd>
<a href='expand/0115-in.jsonld'>expand/0115-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
invalid vocab mapping
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.0</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='t0116'>
Test t0116 Verifies that relative IRIs as properties with relative @vocab in 1.0 generate an error
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#t0116</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Relative property IRIs with relative @vocab in 1.0</dd>
<dt>input</dt>
<dd>
<a href='expand/0116-in.jsonld'>expand/0116-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
invalid vocab mapping
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.0</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tc001'>
Test tc001 adding new term
</dt>
Expand Down Expand Up @@ -8040,6 +8128,202 @@ <h2>
</dd>
</dl>
</dd>
<dt id='tpr33'>
Test tpr33 Fails if trying to declare a keyword alias as prefix.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr33</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Keyword aliases can not be used as prefixes.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr33-in.jsonld'>expand/pr33-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
invalid term definition
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr34'>
Test tpr34 Ignores 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>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</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>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr35'>
Test tpr35 Ignores 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>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</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>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr36'>
Test tpr36 Ignores a term mapping to a value in the form of a keyword.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr36</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr36-in.jsonld'>expand/pr36-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='expand/pr36-out.jsonld'>expand/pr36-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr37'>
Test tpr37 Ignores a term mapping to a value in the form of a keyword (with @vocab).
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr37</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr37-in.jsonld'>expand/pr37-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='expand/pr37-out.jsonld'>expand/pr37-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr38'>
Test tpr38 Ignores a term mapping to a value in the form of a keyword (@reverse).
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr38</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr38-in.jsonld'>expand/pr38-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
invalid IRI mapping
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr39'>
Test tpr39 Ignores a term mapping to a value in the form of a keyword (@reverse with @vocab).
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr39</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Terms in the form of a keyword, which are not keywords, are ignored.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr39-in.jsonld'>expand/pr39-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
invalid IRI mapping
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tso01'>
Test tso01 @import is invalid in 1.0.
</dt>
Expand Down
Loading