Skip to content

Commit

Permalink
Text and tests for using HTML base for embedded JSON-LD.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 1, 2018
1 parent 41d1a1e commit 037b8e4
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4866,6 +4866,14 @@ <h3>The <dfn>JsonLdProcessor</dfn> Interface</h3>
a <a>string</a> representing the <a>IRI</a> of a remote document,
extract the content of the <a>JSON-LD script element</a>(s) into <var>original input</var>:
<ol>
<li>Set <a>base IRI</a> to the the <a data-cite="HTML52/infrastructure.html#document-base-url">Document Base URL</a>
of <var>original input</var>, as defined in [[HTML52]],
using the existing <a>base IRI</a> as the document's URL.
<div class="issue atrisk">
The use of the <a data-cite="HTML52/infrastructure.html#document-base-url">Document Base URL</a>
from [[HTML52]] for setting the <a>base IRI</a> of the enclosed JSON-LD
is an experimental feature, which may be changed in a future version of this specification.
</div>
<li>If the original passed <a data-lt="jsonldprocessor-expand-input">input</a> parameter
contains a <a data-cite="RFC3986#section-3.5">fragment identifier</a>,
set <var>source</var> to the <a data-cite="DOM#dom-node-textcontent">textContent</a>
Expand Down
32 changes: 32 additions & 0 deletions tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,38 @@
"input": "expand/h017-in.html",
"expect": "invalid script element",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#th018",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Expands embedded JSON-LD script element relative to document base",
"purpose": "Tests embedded JSON-LD in HTML",
"input": "expand/h018-in.html",
"expect": "expand/h018-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#th019",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Expands embedded JSON-LD script element relative to base option",
"purpose": "Tests embedded JSON-LD in HTML",
"input": "expand/h019-in.html",
"expect": "expand/h019-out.jsonld",
"option": {"specVersion": "json-ld-1.1", "base": "http://example.org/doc"}
}, {
"@id": "#th020",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Expands embedded JSON-LD script element relative to HTML base",
"purpose": "Tests embedded JSON-LD in HTML",
"input": "expand/h020-in.html",
"expect": "expand/h020-out.jsonld",
"option": {"specVersion": "json-ld-1.1", "base": "http://example.org/doc"}
}, {
"@id": "#th021",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Expands embedded JSON-LD script element relative to relative HTML base",
"purpose": "Tests embedded JSON-LD in HTML",
"input": "expand/h021-in.html",
"expect": "expand/h021-out.jsonld",
"option": {"specVersion": "json-ld-1.1", "base": "http://example.org/doc"}
}, {
"@id": "#tm001",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
Expand Down
13 changes: 13 additions & 0 deletions tests/expand/h018-in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<script type="application/ld+json">
{
"@context": {
"foo": {"@id": "http://example.com/foo"}
},
"@id": "",
"foo": [{"@value": "bar"}]
}
</script>
</head>
</html>
4 changes: 4 additions & 0 deletions tests/expand/h018-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[{
"@id": "https://w3c.github.io/json-ld-api/tests/expand/h018-in.html",
"http://example.com/foo": [{"@value": "bar"}]
}]
13 changes: 13 additions & 0 deletions tests/expand/h019-in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<script type="application/ld+json">
{
"@context": {
"foo": {"@id": "http://example.com/foo"}
},
"@id": "",
"foo": [{"@value": "bar"}]
}
</script>
</head>
</html>
4 changes: 4 additions & 0 deletions tests/expand/h019-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[{
"@id": "http://example.org/doc",
"http://example.com/foo": [{"@value": "bar"}]
}]
14 changes: 14 additions & 0 deletions tests/expand/h020-in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<base href="http://example.org/base" />
<script type="application/ld+json">
{
"@context": {
"foo": {"@id": "http://example.com/foo"}
},
"@id": "",
"foo": [{"@value": "bar"}]
}
</script>
</head>
</html>
4 changes: 4 additions & 0 deletions tests/expand/h020-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[{
"@id": "http://example.org/base",
"http://example.com/foo": [{"@value": "bar"}]
}]
14 changes: 14 additions & 0 deletions tests/expand/h021-in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<base href="base" />
<script type="application/ld+json">
{
"@context": {
"foo": {"@id": "http://example.com/foo"}
},
"@id": "",
"foo": [{"@value": "bar"}]
}
</script>
</head>
</html>
4 changes: 4 additions & 0 deletions tests/expand/h021-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[{
"@id": "http://example.org/base",
"http://example.com/foo": [{"@value": "bar"}]
}]

0 comments on commit 037b8e4

Please sign in to comment.