Skip to content

Add checks for terms including a colon #82

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 2 commits into from
Apr 24, 2019
Merged
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
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,13 @@ <h3>Algorithm</h3>
error has been detected and processing is aborted; if it equals <code>@context</code>, an
<a data-link-for="JsonLdErrorCode">invalid keyword alias</a>
error has been detected and processing is aborted.</li>
<li class="changed">If the <var>term</var> contains a colon (<code>:</code>)
anywhere but as the last character of <var>term</var>,
and the result of expanding <var>term</var>
using the <a href="#iri-expansion">IRI Expansion algorithm</a>
is not the same as the <a>IRI mapping</a> of <var>definition</var>,
an <a data-link-for="JsonLdErrorCode">invalid IRI mapping</a>
error has been detected and processing is aborted.</li>
<li class="changed">If <var>term</var> does not contain a colon (<code>:</code>),
<span class="changed"><var>simple term</var> is <code>true</code></span>, and the,
<a>IRI mapping</a> of <var>definition</var> ends with a URI
Expand Down Expand Up @@ -5937,6 +5944,8 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
<strong>recursive context inclusion</strong> error with a <a data-link-for="JsonLdErrorCode">context overflow</a> error.</li>
<li>Added support for <code>"@type": "@none"</code> in a <a>term definition</a> to prevent value compaction.</li>
<li>Added support for <a>JSON literals</a>.</li>
<li><a>Term definitions</a> with keys which are of the form of a <a>compact IRI</a> or <a>absolute IRI</a> MUST NOT
expand to an <a>IRI</a> other than the expansion of the key itself.</li>
</ul>
</section>

Expand Down
3 changes: 2 additions & 1 deletion tests/compact/ep09-context.jsonld
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"@context": {
"foo:bar": {"@id": "http://example/foo/bar/", "@prefix": true}
"foo": "http://example/foo/",
"foo:bar": {"@id": "http://example/foo/bar", "@prefix": true}
}
}
2 changes: 1 addition & 1 deletion tests/compact/p007-context.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@context": {
"foo": "http://example.org/",
"foo:bar": "foo:baz/"
"foo:bar": {"@type": "@id"}
}
}
4 changes: 2 additions & 2 deletions tests/compact/p007-in.jsonld
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"@id": "http://example.org/baz/a",
"http://example.org/baz/b": "c"
"@id": "http://example.org/bar/a",
"http://example.org/bar/b": "c"
}
6 changes: 3 additions & 3 deletions tests/compact/p007-out.jsonld
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"@context": {
"foo": "http://example.org/",
"foo:bar": "foo:baz/"
"foo:bar": {"@type": "@id"}
},
"@id": "foo:baz/a",
"foo:baz/b": "c"
"@id": "foo:bar/a",
"foo:bar/b": "c"
}
22 changes: 20 additions & 2 deletions tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@
"name": "Term definition with @id: @type",
"purpose": "Expanding term mapping to @type uses @type syntax",
"input": "expand/0026-in.jsonld",
"expect": "expand/0026-out.jsonld"
"expect": "expand/0026-out.jsonld",
"option": {"specVersion": "json-ld-1.0"}
}, {
"@id": "#t0027",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
Expand Down Expand Up @@ -502,7 +503,8 @@
"name": "Redefine terms looking like compact IRIs",
"purpose": "Term definitions may look like compact IRIs",
"input": "expand/0071-in.jsonld",
"expect": "expand/0071-out.jsonld"
"expect": "expand/0071-out.jsonld",
"option": {"specVersion": "json-ld-1.0"}
}, {
"@id": "#t0072",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
Expand Down Expand Up @@ -1225,6 +1227,22 @@
"purpose": "Verifies that an exception is raised on expansion when processing an invalid context attempting to define @container on a keyword",
"input": "expand/e042-in.jsonld",
"expect": "keyword redefinition"
}, {
"@id": "#te043",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Term definition with @id: @type",
"purpose": "Expanding term mapping to @type uses @type syntax now illegal",
"input": "expand/e043-in.jsonld",
Copy link
Contributor

Choose a reason for hiding this comment

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

The label #te043 here doesn't match the input file name prefix e043 (same for e044) -- which seems to break the naming convention, so I suspect this is a typo. Just checking here, was this intentional or a typo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tests all of an identifier such as #txxxx with corresponding files expand/xxxx-in.jsonld and expand/xxx-out.jsonld. In this case the #te043 is consistent with the file named e043-in and follows the same pattern as that for #te042.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the convention has been the test ids have a t prefix, the file names don't. Is that what you meant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the ids all start with a "t", the filename's don't. This convention was established in the 1.0 days. I established the practice if replacing one or two leading zeros with letters to help separate out the new tests by broad feature categorization, which helps in filtering as well.

The #texxx tests typically are for errors, some of which previously came from a separate error manifest.

"expect": "invalid IRI mapping",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#te044",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Redefine terms looking like compact IRIs",
"purpose": "Term definitions may look like compact IRIs, but must be consistent.",
"input": "expand/e044-in.jsonld",
"expect": "invalid IRI mapping",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tec01",
"@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ],
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/0025-in.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": {
"foo": "http://example.com/foo/",
"foo:bar": "http://example.com/bar",
"foo:bar": "http://example.com/foo/bar",
"bar": {"@id": "foo:bar", "@type": "@id"},
"_": "http://example.com/underscore/"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/expand/0025-out.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[{
"@type": [
"http://example.com/foo/",
"http://example.com/bar",
"http://example.com/foo/bar",
"http://example.com/underscore/"
]
}]
20 changes: 20 additions & 0 deletions tests/expand/e043-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"@context": {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type": {"@id": "@type", "@type": "@id"}
},
"@graph": [
{
"@id": "http://example.com/a",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type": "http://example.com/b"
}, {
"@id": "http://example.com/c",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type": [
"http://example.com/d",
"http://example.com/e"
]
}, {
"@id": "http://example.com/f",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type": "http://example.com/g"
}
]
}
11 changes: 11 additions & 0 deletions tests/expand/e044-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": [
{
"v": "http://example.com/vocab#",
"v:term": "v:somethingElse",
"v:termId": { "@id": "v:somethingElseId" }
}
],
"v:term": "value of v:term",
"v:termId": "value of v:termId"
}
15 changes: 15 additions & 0 deletions tests/expand/e045-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"@context": [
{
"v": "http://example.com/vocab#",
"v:term": "v:somethingElse",
"v:termId": { "@id": "v:somethingElseId" }
},
{
"v:term": "v:term",
"v:termId": { "@id": "v:termId" }
}
],
"v:term": "value of v:term",
"v:termId": "value of v:termId"
}
3 changes: 2 additions & 1 deletion tests/flatten-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@
"name": "Term definition with @id: @type",
"purpose": "Flattening term mapping to @type uses @type syntax",
"input": "flatten/0026-in.jsonld",
"expect": "flatten/0026-out.jsonld"
"expect": "flatten/0026-out.jsonld",
"option": {"specVersion": "json-ld-1.0"}
}, {
"@id": "#t0027",
"@type": ["jld:PositiveEvaluationTest", "jld:FlattenTest"],
Expand Down
2 changes: 1 addition & 1 deletion tests/flatten/0025-in.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": {
"foo": "http://example.com/foo/",
"foo:bar": "http://example.com/bar",
"foo:bar": "http://example.com/foo/bar",
"bar": {"@id": "foo:bar", "@type": "@id"},
"_": "http://example.com/underscore/"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/flatten/0025-out.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"@id": "_:b0",
"@type": [
"http://example.com/foo/",
"http://example.com/bar",
"http://example.com/foo/bar",
"http://example.com/underscore/"
]
}
Expand Down
6 changes: 4 additions & 2 deletions tests/toRdf-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@
"name": "Expanding term mapping to @type uses @type syntax",
"purpose": "RDF version of expand-0026",
"input": "toRdf/0066-in.jsonld",
"expect": "toRdf/0066-out.nq"
"expect": "toRdf/0066-out.nq",
"option": {"specVersion": "json-ld-1.0"}
}, {
"@id": "#t0067",
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
Expand Down Expand Up @@ -748,7 +749,8 @@
"name": "Redefine terms looking like compact IRIs",
"purpose": "RDF version of expand-0071",
"input": "toRdf/0111-in.jsonld",
"expect": "toRdf/0111-out.nq"
"expect": "toRdf/0111-out.nq",
"option": {"specVersion": "json-ld-1.0"}
}, {
"@id": "#t0112",
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
Expand Down
2 changes: 1 addition & 1 deletion tests/toRdf/0065-in.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": {
"foo": "http://example.com/foo/",
"foo:bar": "http://example.com/bar",
"foo:bar": "http://example.com/foo/bar",
"bar": {"@id": "foo:bar", "@type": "@id"},
"_": "http://example.com/underscore/"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/toRdf/0065-out.nq
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/bar> .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/foo/> .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/foo/bar> .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/underscore/> .