Skip to content

Commit 037b8e4

Browse files
committed
Text and tests for using HTML base for embedded JSON-LD.
For w3c/json-ld-syntax#23.
1 parent 41d1a1e commit 037b8e4

File tree

10 files changed

+110
-0
lines changed

10 files changed

+110
-0
lines changed

index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4866,6 +4866,14 @@ <h3>The <dfn>JsonLdProcessor</dfn> Interface</h3>
48664866
a <a>string</a> representing the <a>IRI</a> of a remote document,
48674867
extract the content of the <a>JSON-LD script element</a>(s) into <var>original input</var>:
48684868
<ol>
4869+
<li>Set <a>base IRI</a> to the the <a data-cite="HTML52/infrastructure.html#document-base-url">Document Base URL</a>
4870+
of <var>original input</var>, as defined in [[HTML52]],
4871+
using the existing <a>base IRI</a> as the document's URL.
4872+
<div class="issue atrisk">
4873+
The use of the <a data-cite="HTML52/infrastructure.html#document-base-url">Document Base URL</a>
4874+
from [[HTML52]] for setting the <a>base IRI</a> of the enclosed JSON-LD
4875+
is an experimental feature, which may be changed in a future version of this specification.
4876+
</div>
48694877
<li>If the original passed <a data-lt="jsonldprocessor-expand-input">input</a> parameter
48704878
contains a <a data-cite="RFC3986#section-3.5">fragment identifier</a>,
48714879
set <var>source</var> to the <a data-cite="DOM#dom-node-textcontent">textContent</a>

tests/expand-manifest.jsonld

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,38 @@
14331433
"input": "expand/h017-in.html",
14341434
"expect": "invalid script element",
14351435
"option": {"specVersion": "json-ld-1.1"}
1436+
}, {
1437+
"@id": "#th018",
1438+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1439+
"name": "Expands embedded JSON-LD script element relative to document base",
1440+
"purpose": "Tests embedded JSON-LD in HTML",
1441+
"input": "expand/h018-in.html",
1442+
"expect": "expand/h018-out.jsonld",
1443+
"option": {"specVersion": "json-ld-1.1"}
1444+
}, {
1445+
"@id": "#th019",
1446+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1447+
"name": "Expands embedded JSON-LD script element relative to base option",
1448+
"purpose": "Tests embedded JSON-LD in HTML",
1449+
"input": "expand/h019-in.html",
1450+
"expect": "expand/h019-out.jsonld",
1451+
"option": {"specVersion": "json-ld-1.1", "base": "http://example.org/doc"}
1452+
}, {
1453+
"@id": "#th020",
1454+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1455+
"name": "Expands embedded JSON-LD script element relative to HTML base",
1456+
"purpose": "Tests embedded JSON-LD in HTML",
1457+
"input": "expand/h020-in.html",
1458+
"expect": "expand/h020-out.jsonld",
1459+
"option": {"specVersion": "json-ld-1.1", "base": "http://example.org/doc"}
1460+
}, {
1461+
"@id": "#th021",
1462+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1463+
"name": "Expands embedded JSON-LD script element relative to relative HTML base",
1464+
"purpose": "Tests embedded JSON-LD in HTML",
1465+
"input": "expand/h021-in.html",
1466+
"expect": "expand/h021-out.jsonld",
1467+
"option": {"specVersion": "json-ld-1.1", "base": "http://example.org/doc"}
14361468
}, {
14371469
"@id": "#tm001",
14381470
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],

tests/expand/h018-in.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html>
2+
<head>
3+
<script type="application/ld+json">
4+
{
5+
"@context": {
6+
"foo": {"@id": "http://example.com/foo"}
7+
},
8+
"@id": "",
9+
"foo": [{"@value": "bar"}]
10+
}
11+
</script>
12+
</head>
13+
</html>

tests/expand/h018-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[{
2+
"@id": "https://w3c.github.io/json-ld-api/tests/expand/h018-in.html",
3+
"http://example.com/foo": [{"@value": "bar"}]
4+
}]

tests/expand/h019-in.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html>
2+
<head>
3+
<script type="application/ld+json">
4+
{
5+
"@context": {
6+
"foo": {"@id": "http://example.com/foo"}
7+
},
8+
"@id": "",
9+
"foo": [{"@value": "bar"}]
10+
}
11+
</script>
12+
</head>
13+
</html>

tests/expand/h019-out.jsonld

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

tests/expand/h020-in.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<head>
3+
<base href="http://example.org/base" />
4+
<script type="application/ld+json">
5+
{
6+
"@context": {
7+
"foo": {"@id": "http://example.com/foo"}
8+
},
9+
"@id": "",
10+
"foo": [{"@value": "bar"}]
11+
}
12+
</script>
13+
</head>
14+
</html>

tests/expand/h020-out.jsonld

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

tests/expand/h021-in.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<head>
3+
<base href="base" />
4+
<script type="application/ld+json">
5+
{
6+
"@context": {
7+
"foo": {"@id": "http://example.com/foo"}
8+
},
9+
"@id": "",
10+
"foo": [{"@value": "bar"}]
11+
}
12+
</script>
13+
</head>
14+
</html>

tests/expand/h021-out.jsonld

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

0 commit comments

Comments
 (0)