@@ -8401,80 +8401,6 @@ <h3>Graph Containers</h3>
8401
8401
</ pre >
8402
8402
</ aside >
8403
8403
8404
- < p > Depending on how the HTML document is served, certain strings may need
8405
- to be escaped. See
8406
- < a href ="https://www.w3.org/TR/html52/semantics-scripting.html#restrictions-for-contents-of-script-elements ">
8407
- Restrictions for contents of < code > script</ code > elements
8408
- </ a > in [[!HTML52]] for details. In particular, the content MAY be enclosed
8409
- in the HTML comment open (< code > <!--</ code > ) and comment close (< code > --></ code > ) text sequences</ p >
8410
-
8411
- < aside class ="example ds-selector-tabs "
8412
- title ="Embedding JSON-LD in HTML with comments ">
8413
- < div class ="selectors ">
8414
- < button class ="selected " data-selects ="original "> Original</ button >
8415
- < button data-selects ="expanded "> Expanded</ button >
8416
- < button data-selects ="statements "> Statements</ button >
8417
- < button data-selects ="turtle "> Turtle</ button >
8418
- </ div >
8419
- < pre class ="original selected " data-transform ="updateExample "
8420
- data-content-type ="text/html ">
8421
- <!--
8422
- <script type="application/ld+json">
8423
- < !--
8424
- {
8425
- "@context": "https://json-ld.org/contexts/person.jsonld",
8426
- "@id": "http://dbpedia.org/resource/John_Lennon",
8427
- "name": "John Lennon",
8428
- "born": "1940-10-09",
8429
- "spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
8430
- }
8431
- -- >
8432
- </script>
8433
- -->
8434
- </ pre >
8435
- < pre class ="expanded "
8436
- data-transform ="updateExample "
8437
- data-result-for ="Embedding JSON-LD in HTML with comments-original ">
8438
- <!--
8439
- [{
8440
- "@id": "http://dbpedia.org/resource/John_Lennon",
8441
- "http://xmlns.com/foaf/0.1/name": [{"@value": "John Lennon"}],
8442
- "http://schema.org/birthDate": [
8443
- {"@value": "1940-10-09", "@type": "http://www.w3.org/2001/XMLSchema#date"}
8444
- ],
8445
- "http://schema.org/spouse": [
8446
- {"@id": "http://dbpedia.org/resource/Cynthia_Lennon"}
8447
- ]
8448
- }]
8449
- -->
8450
- </ pre >
8451
- < table class ="statements "
8452
- data-result-for ="Embedding JSON-LD in HTML with comments-expanded "
8453
- data-to-rdf >
8454
- < thead > < tr > < th > Subject</ th > < th > Property</ th > < th > Value</ th > < th > Value Type</ th > </ tr > </ thead >
8455
- < tbody >
8456
- < tr > < td > http://dbpedia.org/resource/John_Lennon</ td > < td > foaf:name</ td > < td > John Lennon</ td > < td > </ td > </ tr >
8457
- < tr > < td > http://dbpedia.org/resource/John_Lennon</ td > < td > schema:birthDate</ td > < td > 1940-10-09</ td > < td > xsd:date</ td > </ tr >
8458
- < tr > < td > http://dbpedia.org/resource/John_Lennon</ td > < td > schema:spouse</ td > < td > http://dbpedia.org/resource/Cynthia_Lennon</ td > < td > </ td > </ tr >
8459
- </ tbody >
8460
- </ table >
8461
- < pre class ="turtle "
8462
- data-content-type ="text/turtle "
8463
- data-transform ="updateExample "
8464
- data-result-for ="Embedding JSON-LD in HTML with comments-expanded "
8465
- data-to-rdf >
8466
- <!--
8467
- @prefix foaf: <http://xmlns.com/foaf/0.1/> .
8468
- @prefix schema: <http://schema.org/> .
8469
- @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8470
-
8471
- <http://dbpedia.org/resource/John_Lennon> foaf:name "John Lennon";
8472
- schema:birthDate "1940-10-09"^^xsd:date;
8473
- schema:spouse <http://dbpedia.org/resource/Cynthia_Lennon> .
8474
- -->
8475
- </ pre >
8476
- </ aside >
8477
-
8478
8404
< p > Defining how such data may be used is beyond the scope of this specification.
8479
8405
The embedded JSON-LD document might be extracted as is or, e.g., be
8480
8406
interpreted as RDF.</ p >
@@ -8564,6 +8490,109 @@ <h3>Graph Containers</h3>
8564
8490
containing HTML document is used to establish the default < a > base IRI</ a > of the enclosed
8565
8491
JSON-LD content.</ p >
8566
8492
8493
+ < section > < h3 > Restrictions for contents of JSON-LD < code > script</ code > elements</ h3 >
8494
+
8495
+ < p > Depending on how the HTML document is served, certain strings may need
8496
+ to be escaped. In particular, the content MAY be enclosed
8497
+ in the HTML < em > comment-open</ em > (< code > <!--</ code > ) and < em > comment-close</ em > (< code > --></ code > ) text sequences.</ p >
8498
+ < p > As described in HTML < a data-cite ="HTML52/semantics-scripting.html#restrictions-for-contents-of-script-elements "> Restrictions for contents of < code > <script></ code > elements</ a >
8499
+ the < a data-cite ="DOM#dom-node-textcontent "> textContent</ a > of a script element may include balanced comments
8500
+ and other text which complicate extracting the JSON-LD content from a < a data-cite ="HTML52/semantics-scripting.html#data-block "> data blocks</ a > .
8501
+ JSON-LD places further restrictions on the contents of
8502
+ < a data-cite ="HTML52/semantics-scripting.html#the-script-element "> script elements</ a > containing JSON-LD.</ p >
8503
+ < p > A JSON-LD script element MAY begin with an optional < em > comment-open</ em > surrounded by any amount of white space,
8504
+ followed by valid JSON and ending with an optional < em > comment-close</ em > surrounded by any amount of white space.
8505
+ Any content within the JSON content which can be confused with a < em > comment-open</ em > , < em > script-open</ em > ,
8506
+ < em > comment-close</ em > , or < em > script-close</ em > MUST be escaped using a REVERSE SOLIDUS (< code > \</ code > ) character
8507
+ as follows:</ p >
8508
+ < ul >
8509
+ < li > < code > <!--</ code > → < code > <\!--</ code > </ li >
8510
+ < li > < code > <script</ code > → < code > <\script</ code > </ li >
8511
+ < li > < code > --></ code > → < code > --\></ code > </ li >
8512
+ < li > < code > </script</ code > → < code > <\/script</ code > </ li >
8513
+ </ ul >
8514
+ < p > Additionally, content of a script element MAY be escaped using < a data-cite ="HTML5/syntax.html#character-references "> HTML Character references</ a > , such as the following:</ p >
8515
+ < ul >
8516
+ < li > < code > &amp;</ code > → & (< a href ="/wiki/Ampersand " title ="Ampersand "> ampersand</ a > , U+0026)</ li >
8517
+ < li > < code > &lt;</ code > → < (less-than sign, U+003C)</ li >
8518
+ < li > < code > &gt;</ code > → > (greater-than sign, U+003E)</ li >
8519
+ < li > < code > &quot;</ code > → " (quotation mark, U+0022)</ li >
8520
+ < li > < code > &apos;</ code > → ' (apostrophe, U+0027)</ li >
8521
+ </ ul >
8522
+ < p > JSON-LD Processors MUST remove surrounding < em > comment-open</ em > and < em > comment-close</ em >
8523
+ sequences, unescape any escaped < em > comment-open</ em > , < em > comment-close</ em > ,
8524
+ < em > script-open</ em > , and < em > script-close</ em > sequences,
8525
+ and turn < a data-cite ="HTML5/syntax.html#character-references "> HTML Character references</ a > into the corresponding Unicode.
8526
+ </ p >
8527
+
8528
+ < aside class ="example ds-selector-tabs "
8529
+ title ="Embedding JSON-LD in HTML with comments ">
8530
+ < div class ="selectors ">
8531
+ < button class ="selected " data-selects ="original "> Original</ button >
8532
+ < button data-selects ="expanded "> Expanded</ button >
8533
+ < button data-selects ="statements "> Statements</ button >
8534
+ < button data-selects ="turtle "> Turtle</ button >
8535
+ </ div >
8536
+ < pre class ="original selected " data-transform ="updateExample "
8537
+ data-content-type ="text/html ">
8538
+ <!--
8539
+ <script type="application/ld+json">
8540
+ < !--
8541
+ {
8542
+ "@context": "https://json-ld.org/contexts/person.jsonld",
8543
+ "@id": "http://dbpedia.org/resource/John_Lennon",
8544
+ "name": "John Lennon",
8545
+ "born": "1940-10-09",
8546
+ "spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
8547
+ }
8548
+ -- >
8549
+ </script>
8550
+ -->
8551
+ </ pre >
8552
+ < pre class ="expanded "
8553
+ data-transform ="updateExample "
8554
+ data-result-for ="Embedding JSON-LD in HTML with comments-original ">
8555
+ <!--
8556
+ [{
8557
+ "@id": "http://dbpedia.org/resource/John_Lennon",
8558
+ "http://xmlns.com/foaf/0.1/name": [{"@value": "John Lennon"}],
8559
+ "http://schema.org/birthDate": [
8560
+ {"@value": "1940-10-09", "@type": "http://www.w3.org/2001/XMLSchema#date"}
8561
+ ],
8562
+ "http://schema.org/spouse": [
8563
+ {"@id": "http://dbpedia.org/resource/Cynthia_Lennon"}
8564
+ ]
8565
+ }]
8566
+ -->
8567
+ </ pre >
8568
+ < table class ="statements "
8569
+ data-result-for ="Embedding JSON-LD in HTML with comments-expanded "
8570
+ data-to-rdf >
8571
+ < thead > < tr > < th > Subject</ th > < th > Property</ th > < th > Value</ th > < th > Value Type</ th > </ tr > </ thead >
8572
+ < tbody >
8573
+ < tr > < td > http://dbpedia.org/resource/John_Lennon</ td > < td > foaf:name</ td > < td > John Lennon</ td > < td > </ td > </ tr >
8574
+ < tr > < td > http://dbpedia.org/resource/John_Lennon</ td > < td > schema:birthDate</ td > < td > 1940-10-09</ td > < td > xsd:date</ td > </ tr >
8575
+ < tr > < td > http://dbpedia.org/resource/John_Lennon</ td > < td > schema:spouse</ td > < td > http://dbpedia.org/resource/Cynthia_Lennon</ td > < td > </ td > </ tr >
8576
+ </ tbody >
8577
+ </ table >
8578
+ < pre class ="turtle "
8579
+ data-content-type ="text/turtle "
8580
+ data-transform ="updateExample "
8581
+ data-result-for ="Embedding JSON-LD in HTML with comments-expanded "
8582
+ data-to-rdf >
8583
+ <!--
8584
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
8585
+ @prefix schema: <http://schema.org/> .
8586
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8587
+
8588
+ <http://dbpedia.org/resource/John_Lennon> foaf:name "John Lennon";
8589
+ schema:birthDate "1940-10-09"^^xsd:date;
8590
+ schema:spouse <http://dbpedia.org/resource/Cynthia_Lennon> .
8591
+ -->
8592
+ </ pre >
8593
+ </ aside >
8594
+ </ section >
8595
+
8567
8596
< section > < h3 > Locating a Specific JSON-LD Script Element</ h3 >
8568
8597
< p > A specific
8569
8598
< a data-cite ="HTML52/semantics-scripting.html#the-script-element "> script element</ a >
0 commit comments