From 83f6309a8af78640faa32249041d458b4b45d403 Mon Sep 17 00:00:00 2001 From: Anatoly Scherbakov Date: Thu, 4 May 2023 21:47:47 +0400 Subject: [PATCH] =?UTF-8?q?#97=20Convert=20Extended=20=E2=86=92=20Basic=20?= =?UTF-8?q?YAML-LD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/index.html | 119 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 3 deletions(-) diff --git a/spec/index.html b/spec/index.html index a2274a0..c218e6b 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1390,9 +1390,7 @@

Reduce duplication

- -

Two alternative approaches have been proposed to implement the Extended profile:

@@ -2383,12 +2381,127 @@

YamlLdErrorCode

+
+

Implementations

+ + TODO +
+

Convert Extended YAML-LD to Basic YAML-LD and back

- TODO +

+ This approach is simpler than the Extended Internal Representation because it + does not require any changes to the internal structures of existing JSON-LD + libraries. +

+ +

+ Instead, we implement two API functions: +

+ +
+
extended_to_basic(extended_document: YAML-LD) → YAML-LD
+
+ Converts an Extended YAML-LD document to a JSON-LD document that a standard + processor can work with +
+ +
basic_to_extended(basic_document: JSON-LD | YAML-LD) → YAML-LD
+
+ Converts a basic JSON-LD or YAML-LD document to the Extended form, making + use of YAML-LD features to express the document more concisely. +
+
+ +

+ Both of these functions recursively process the source document. + Every branch and leaf are copied as is, unless they match one of the following + cases. +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
extended_to_basicbasic_to_extended
YAML Tags + Convert YAML !tags + → @type JSON-LD keywords + (nothing)
Anchors and aliasesResolve anchors and aliases(nothing)
Comments + Keep as-is +
+ +
+

YAML !tags@type declarations

+ +
+
+
+                  %TAG !xsd: http://www.w3.org/2001/XMLSchema%23
+                  ---
+                  "@context":
+                    schema: https://schema.org/
+                  "@id": https://yaml-ld.example
+                  schema:dateModified: !xsd:date 2023-03-21
+                
+
+
+
+                  "@context":
+                    schema: https://schema.org/
+                    xsd: http://www.w3.org/2001/XMLSchema#
+                  "@id": https://yaml-ld.example
+                  schema:dateModified:
+                    "@type": xsd:date
+                    "@value": "2023-03-21"
+                
+
+
+
+ +
+

&anchors and *aliases

+ +

+ Substitute every *alias with the content of + the &anchor alias references to. This is standard behavior + of YAML tools and libraries. +

+