Skip to content

Commit 1460c08

Browse files
#94 Move explanation about comments: FAQ → Comments section
1 parent 6e779fa commit 1460c08

File tree

1 file changed

+71
-59
lines changed

1 file changed

+71
-59
lines changed

spec/index.html

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,76 @@ <h2>Encoding</h2>
731731
</section>
732732

733733
<section id="comments">
734-
<h2>Comments</h2>
735-
<p id="cr-comments" data-tests="basic-manifest.html#cr-comments-1-positive">
736-
Comments in <a>YAML-LD documents</a> are treated as white space.
737-
This behavior is consistent with other Linked Data serializations such as [[?TURTLE]].
738-
See Interoperability considerations of [[I-D.ietf-httpapi-yaml-mediatypes]]
739-
for more details.
740-
</p>
734+
<h2>Comments</h2>
735+
<p id="cr-comments" data-tests="basic-manifest.html#cr-comments-1-positive">
736+
Comments in <a>YAML-LD documents</a> are treated as white space.
737+
</p>
738+
739+
<section>
740+
<h2>Consistency</h2>
741+
742+
<dl>
743+
<dt>[[?TURTLE]] and other Linked Data serializations which support comments</dt>
744+
<dd>…do not provide a means to preserve them
745+
when processing and serializing the document
746+
in other formats</dd>
747+
748+
<dt>YAML</dt>
749+
<dd>
750+
requires that parts of the document not reflected by
751+
752+
<a>representation graph</a>, such as
753+
754+
<ul>
755+
<li>comments</li>
756+
<li>directives</li>
757+
<li>mapping key order</li>
758+
<li>anchor names</li>
759+
</ul>
760+
761+
must not be used to convey application level information
762+
</dd>
763+
</dl>
764+
</section>
765+
766+
<section>
767+
<h2>Predictability</h2>
768+
769+
<p>
770+
Theoretically, we could try harvesting YAML comments into
771+
JSON-LD documents. We would define a specific predicate, like
772+
<code>https://json-ld.org/yaml-ld/comment</code>, and convert
773+
every <code># My comment</code> fragment into
774+
<code>{"yaml-ld:comment": "My comment"}</code> piece in JSON-LD
775+
document.
776+
</p>
777+
778+
<p>
779+
This would, however, make implementation:
780+
</p>
781+
782+
<ul>
783+
<li>
784+
More complicated because most industrially available YAML
785+
parsers discard comments on reading YAML data
786+
</li>
787+
<li>
788+
Less predictable because, in JSON, order of keys is not
789+
preserved — and therefore, when converting a JSON-LD document
790+
back to YAML-LD, comments might be displaced.
791+
</li>
792+
</ul>
793+
</section>
794+
795+
<p>
796+
This specification does not provide a means for preserving
797+
[[YAML]] comments after a JSON serialization.
798+
</p>
799+
800+
<p>
801+
See Interoperability considerations of [[I-D.ietf-httpapi-yaml-mediatypes]]
802+
for more details.
803+
</p>
741804
</section>
742805

743806
<section id="anchors-aliases">
@@ -1020,59 +1083,8 @@ <h3>application/ld+yaml</h3>
10201083

10211084
<h3>FAQ</h3>
10221085

1023-
#### Why does YAML-LD not preserve comments?
1024-
<div class="ednote">
1025-
According to [[YAML]], information that does not reflect
1026-
into the <a>representation graph</a> (e.g., comments, directives, mapping keys order,
1027-
anchor names, ...) must not be used to convey application level information.
1028-
Moreover
1029-
[[JSON]] (and hence [[JSON-LD11]]) does not support comments,
1030-
and other Linked Data serialization formats
1031-
that support comments (such as [[?TURTLE]])
1032-
do not provide a means to preserve them
1033-
when processing and serializing the document
1034-
in other formats.
1035-
The proposed behavior is thus consistent with
1036-
other implementations.
1037-
1038-
While YAML-LD could define a specific predicate for comments,
1039-
that is insufficient because, for example,
1040-
the order of keywords is not preserved in JSON, so the
1041-
comments could be displaced.
1042-
This specification does not provide a means for preserving
1043-
[[YAML]] comments after a JSON serialization.
1044-
1045-
<pre class="example yaml"
1046-
data-transform="updateExample"
1047-
data-content-type="application/ld+yaml"
1048-
title="YAML-LD with comments">
1049-
<!--
1050-
# First comment
1051-
"@context": "http://schema.org/"
1052-
1053-
# Second comment
1054-
givenName: John
1055-
-->
1056-
</pre>
1057-
1058-
Transforming the above entry into a JSON-LD document
1059-
results in:
1060-
1061-
<pre class="example json"
1062-
data-transform="updateExample"
1063-
data-result-for="YAML-LD with comments"
1064-
data-content-type="application/ld+json"
1065-
title="Result of parsing YAML-LD with comments to JSON-LD">
1066-
<!--
1067-
{
1068-
"@context": "http://schema.org/",
1069-
"givenName": "John"
1070-
}
1071-
-->
1072-
</pre>
1073-
</div>
1074-
10751086
#### Why does YAML-LD not extend the JSON-LD data model ?
1087+
10761088
<div class="ednote">
10771089
[[JSON]] only represents simple trees while [[YAML]] can support
10781090
rooted, directed graphs with references and cycles.

0 commit comments

Comments
 (0)