From 4e0fa2e6893de6e7c8280802a948f3931facedb5 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Mon, 26 Jun 2023 02:30:19 +0400 Subject: [PATCH] =?UTF-8?q?#94=20Move=20explanation=20about=20comments:=20?= =?UTF-8?q?FAQ=20=E2=86=92=20Comments=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/index.html | 130 ++++++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 59 deletions(-) diff --git a/spec/index.html b/spec/index.html index bf0625c..3b12f33 100644 --- a/spec/index.html +++ b/spec/index.html @@ -731,13 +731,76 @@

Encoding

-

Comments

-

- Comments in YAML-LD documents are treated as white space. - This behavior is consistent with other Linked Data serializations such as [[?TURTLE]]. - See Interoperability considerations of [[I-D.ietf-httpapi-yaml-mediatypes]] - for more details. -

+

Comments

+

+ Comments in YAML-LD documents are treated as white space. +

+ +
+

Consistency

+ +
+
[[?TURTLE]] and other Linked Data serializations which support comments
+
…do not provide a means to preserve them + when processing and serializing the document + in other formats
+ +
YAML
+
+ requires that parts of the document not reflected by + + representation graph, such as + +
    +
  • comments
  • +
  • directives
  • +
  • mapping key order
  • +
  • anchor names
  • +
+ + must not be used to convey application level information +
+
+
+ +
+

Predictability

+ +

+ Theoretically, we could try harvesting YAML comments into + JSON-LD documents. We would define a specific predicate, like + https://json-ld.org/yaml-ld/comment, and convert + every # My comment fragment into + {"yaml-ld:comment": "My comment"} piece in JSON-LD + document. +

+ +

+ This would, however, make implementation: +

+ +
    +
  • + More complicated because most industrially available YAML + parsers discard comments on reading YAML data +
  • +
  • + Less predictable because, in JSON, order of keys is not + preserved — and therefore, when converting a JSON-LD document + back to YAML-LD, comments might be displaced. +
  • +
+
+ +

+ This specification does not provide a means for preserving + [[YAML]] comments after a JSON serialization. +

+ +

+ See Interoperability considerations of [[I-D.ietf-httpapi-yaml-mediatypes]] + for more details. +

@@ -1020,59 +1083,8 @@

application/ld+yaml

FAQ

- #### Why does YAML-LD not preserve comments? -
- According to [[YAML]], information that does not reflect - into the representation graph (e.g., comments, directives, mapping keys order, - anchor names, ...) must not be used to convey application level information. - Moreover - [[JSON]] (and hence [[JSON-LD11]]) does not support comments, - and other Linked Data serialization formats - that support comments (such as [[?TURTLE]]) - do not provide a means to preserve them - when processing and serializing the document - in other formats. - The proposed behavior is thus consistent with - other implementations. - - While YAML-LD could define a specific predicate for comments, - that is insufficient because, for example, - the order of keywords is not preserved in JSON, so the - comments could be displaced. - This specification does not provide a means for preserving - [[YAML]] comments after a JSON serialization. - -
-      
-    
- - Transforming the above entry into a JSON-LD document - results in: - -
-      
-    
-
- #### Why does YAML-LD not extend the JSON-LD data model ? +
[[JSON]] only represents simple trees while [[YAML]] can support rooted, directed graphs with references and cycles.