From 120883ee07c33c8fca30fbbed692bccbe489bb56 Mon Sep 17 00:00:00 2001
From: Anatoly Scherbakov Introduction
such that any YAML-LD document can be represented in JSON-LD.
- To take better advantage of the broader expressivity of YAML, - this document also defines a means of extending the - JSON-LD internal representation to allow a more complete expression - of native data types within YAML-LD, and allows use of the complete - [[[JSON-LD11-API]]] [[JSON-LD11-API]] - - Application Programming Interface - - to manipulate extended YAML-LD documents. -
-- A YAML-LD document complies with - the YAML-LD extended profile of this specification - if it follows the normative statements from this specification - and can be transformed into the - JSON-LD extended internal representation, - then back to a conforming YAML-LD document, - without loss of semantic information. -
-- As [[YAML]] has well-defined representation requirements, - all YAML-LD streams MUST form a - - well-formed stream - - and use alias node defined by a previous node - with a corresponding anchor; - otherwise, a - loading-document-failed - error has been detected and processing is aborted. -
-- When processing using the YAML-LD JSON profile, - documents MUST NOT contain alias nodes; - otherwise, a - profile-error - error has been detected and processing is aborted. - The YAML-LD extended profile allows full use of - anchor names and alias nodes subject to - the requirements described above in this section. -
The YAML-LD document in the following example @@ -825,1327 +774,1397 @@
YAML-LD processing is defined by converting YAML to the - internal representation and using [[[JSON-LD11-API]]] - to process on that representation, - after which the representation is converted back to YAML. - As information specific to a given YAML document structure is lost - in this transformation, much of the specifics of that - original representation are therefore lost in that conversion, - limiting the ability to fully round-trip a YAML-LD document back - to an equivalent representation. - Consequently, round-tripping in this context is limited to preservation of the semantic - representation of a document, - rather than a specific syntactic representation.
- -- If the {{JsonLdOptions/extendedYAML}} API flag is `true`, the processing result - will be in the extended internal representation. -
- - - -The conversion process represented here is compatible with - the description of - "Composing the Representation Graph" from the - 3.1.2 Load section of [[YAML]]. - The steps described below for converting to the - internal representation operate upon that - . -
+When operating using the YAML-LD JSON profile, - it is intended that the common feature provided by most - YAML libraries of transforming YAML directly to JSON - satisfies the requirements for parsing a YAML-LD file. +
+ For general interoperability considerations on the serialization of + JSON documents in [[YAML]], see YAML + and the Interoperability consideration of application/yaml [[I-D.ietf-httpapi-yaml-mediatypes]].
- -- As a developer, - I want to be able to convert JSON-LD documents to YAML-LD by simply serializing the document using any standard YAML library, - So that the resulting YAML is valid YAML-LD, resolving to the same graph as the original JSON-LD. +
+ The YAML-LD format and the media type registration are not restricted to a specific + version of YAML, + but implementers that want to use YAML-LD with YAML versions + other than 1.2.2 need to be aware that the considerations and analysis provided + here, including interoperability and security considerations, are based + on the YAML 1.2.2 specification.
+A YAML stream is composed of zero or more YAML documents.
+- YAML streams may correspond more directly to - [[[RFC7464]]], which are not presently part of the - JSON-LD representation model. - The description here more closely aligns with how JSON-LD - interprets HTML Scripts. -
+This section has been submitted to the Internet Engineering Steering + Group (IESG) for review, approval, and registration with IANA.
++ This section describes the information required to register the above media type according to [[RFC6838]] +
-- Any error reported in a recursive processing step MUST result - in the failure of this processing step.
+profile
A non-empty list of space-separated URIs identifying specific
+ constraints or conventions that apply to a YAML-LD document according to [[RFC6906]].
+ A profile does not change the semantics of the resource representation
+ when processed without profile knowledge, so that clients both with
+ and without knowledge of a profiled resource can safely use the same
+ representation. The profile
parameter MAY be used by
+ clients to express their preferences in the content negotiation process.
+ If the profile parameter is given, a server SHOULD return a document that
+ honors the profiles in the list which it recognizes,
+ and MUST ignore the profiles in the list which it does not recognize.
+ It is RECOMMENDED that profile URIs are dereferenceable and provide
+ useful documentation at that URI. For more information and background
+ please refer to [[RFC6906]].
This specification allows the use of the `profile` parameters listed in + and additionally defines the following: +
+http://www.w3.org/ns/json-ld#extended
+ When used as a media type parameter [[RFC4288]]
+ in an HTTP Accept header field [[RFC9110]],
+ the value of the profile
parameter MUST be enclosed in quotes ("
) if it contains
+ special characters such as whitespace, which is required when multiple profile URIs are combined.
When processing the "profile" media type parameter, it is important to + note that its value contains one or more URIs and not IRIs. In some cases + it might therefore be necessary to convert between IRIs and URIs as specified in + section 3 Relationship between IRIs and URIs + of [[RFC3987]].
+From the YAML grammar,
- a YAML document MAY be preceded by a
- Document Prefix
- and/or a set of
- directives
- followed by a
- YAML bare document,
- which is composed of a single node.
+ Fragment identifiers used with application/ld+yaml
+ are treated as in RDF syntaxes, as per
+ RDF 1.1 Concepts and Abstract Syntax
+ [[RDF11-CONCEPTS]]
+ and do not follow the process defined for application/yaml.
- Any error reported in a recursive processing step MUST result
- in the failure of this processing step. Both block sequences and flow sequences
- are directly aligned with
- an array in the internal representation.
- Any error reported in a recursive processing step MUST result
- in the failure of this processing step. FIXME Both block mappings and flow mappings
- are directly aligned with
- a map in the internal representation. REMOVE THIS SECTION BEFORE PUBLICATION.
- Any error reported in a recursive processing step MUST result
- in the failure of this processing step.
- Implementations may retain the
- representation as an YAML Integer,
- or YAML Floating Point,
- but a JSON-LD processor must treat them uniformly
- as a number, although the specific type of number
- value SHOULD be retained for round-tripping.
-
- If an alias node is encountered when processing the
- YAML representation graph
- and the {{JsonLdOptions/extendedYAML}} flag is `false`,
- the YAML-LD JSON profile has been selected.
- A profile-error
- error has been detected and processing MUST be aborted.
-
- If a cycle is detected,
- a processing error MUST be returned,
- and processing aborted.
- The conversion process from the internal representation
- involves turning that representation back into a YAML
- representation graph
- and relies on the description of
- "Serializing the Representation Graph" from the
- 3.1.1 Dump section of [[YAML]]
- for the final serialization.
-
- As the internal representation is rooted by either
- an array or a map,
- the process of transforming the internal representation
- to YAML begins by preparing an empty representation graph
- which will be rooted with either a
- YAML mapping or YAML sequence.
-
- Although outside of the scope of this specification,
- processors MAY use
- YAML directives, including TAG directives, and
- Document markers,
- as appropriate for best results.
- Specifically, if the {{JsonLdOptions/extendedYAML}} API flag is `true`,
- the document SHOULD use the `%YAML` directive with
- version set to at least `1.2`.
- To improve readability and reduce document size,
- the document MAY use a `%TAG` directive appropriate for
- RDF literals contained within the representation.
-
- The use of `%TAG` directives in YAML-LD is similar to the use
- of the `PREFIX` directive in [[?Turtle]]
- or the general use of terms as prefixes to create
- Compact IRIs in [[JSON-LD11]]:
- they not change the meaning of the encoded scalars.
-
- Although allowed within the YAML Grammar, some current YAML parsers
- do not allow the use of `"#"` within a tag URI. Substituting
- the `"%23"` escape is a workaround for this problem, that will
- hopefully become unnecessary as implementations are updated.
- A concrete proposal in that direction would be to use a tag at the
- top-level of any "idiomatic" YAML-LD document, applying to the whole
- object/array that makes the document. It might also include a version
- to identify the specification that it relates to, allowing
- for version announcement that could be used for future-proofing. The following block is one example: See for an example of serializing the extended internal representation. Here, we propose to YAML-LD users a bit of advice which, although optional, might suggest one or two
+ useful thoughts.
+ Follow JSON-LD best practices
+ …in order to achieve a greater level of reusability, performance, and human friendliness among YAML-LD aware
+ systems. The [[json-ld-bp]] document is as relevant to YAML-LD as it is to [[JSON-LD11]].
+
- This algorithm describes the steps to convert
- each element from the internal representation
- into corresponding YAML nodes by recursively
- processing each element |n|.
-
+ Do not force users to author contexts
- YAML-LD is intended to simplify the authoring of Linked Data for a wide range of domain experts; its target
+ audience is not comprised solely of IT professionals. [[YAML]] is chosen as a medium to minimize syntactic noise,
+ and to keep the authored documents concise and clear. [[JSON-LD11]] (and hence YAML-LD) Context comprises a special
+ language of its own. A requirement to author such a context would make the domain expert's job much
+ harder, which we, as system architects and developers, should try to avoid. This section identifies two application profiles for operating with
- YAML-LD:
+ Use a default context
+ Application profiles allow publishers to use YAML-LD
- either for maximum interoperability,
- or for maximum expressivity.
- The YAML-LD JSON profile provides for complete round-tripping
- between YAML-LD documents and JSON-LD documents.
- The YAML-LD extended profile allows for
- fuller use of YAML features to enhance the ability to
- represent a larger number of native datatypes
- and reduce document redundancy. For instance, according to [[JSON-LD11-API]], the `expand()` method of a JSON-LD processor accepts an
+ `expandContext` argument which can be used to provide a default system context.
+ Alias JSON-LD keywords
+
+ If possible, map JSON-LD keywords containing the `@` character to keywords that do not contain it.
+ The `@` character is reserved in YAML, and thus requires quoting (or escaping), as in the following
+ example: The need to quote these keywords has to be learnt, and introduces one more little irregularity to the document
+ author's life. Further, on most keyboard layouts, typing quotes will require `Shift`, which reduces typing speed,
+ albeit slightly. In order to avoid this, the context might introduce custom mappings for the necessary keywords. For instance,
+ [[schema-org]] context redefines `@id` as just `id` — which seems to be much more convenient to type, and
+ no more difficult to remember.
+ Use YAML-LD Convenience Context
+ YAML-LD users may use a JSON-LD context provided as part of this specification, henceforth known as the
+ convenience context, which defines a standardized mapping of every `@`-keyword to a `$`-keyword, except `@context`.
+ The convenience context contains an alias to every JSON-LD keyword which the JSON-LD 1.1
+ specification permits aliasing — which means all the keywords except Application profiles can be set using the {{JsonLdProcessor}}
- API interface, as well as an HTTP request profile (see ). The applicability of this context depends on the domain and is left to the architect's best judgement.
- The YAML-LD JSON profile
- is based on the YAML Core Schema,
- which interprets only a limited set of node tags.
- YAML scalars with node tags outside of the defined range
- SHOULD be avoided and MUST be converted to the closest
- scalar type from the YAML Core Schema,
- if found.
- See
- for specifics.
+ To take better advantage of the broader expressivity of YAML,
+ this document also defines a means of extending the
+ JSON-LD internal representation to allow a more complete expression
+ of native data types within YAML-LD, and allows use of the complete
+ [[[JSON-LD11-API]]] [[JSON-LD11-API]]
+
+ Application Programming Interface
+
+ to manipulate extended YAML-LD documents.
+ A YAML-LD document complies with
+ the YAML-LD extended profile of this specification
+ if it follows the normative statements from this specification
+ and can be transformed into the
+ JSON-LD extended internal representation,
+ then back to a conforming YAML-LD document,
+ without loss of semantic information.
- Keys used in a YAML mapping MUST be strings.
+
+ As [[YAML]] has well-defined representation requirements,
+ all YAML-LD streams MUST form a
+
+ well-formed stream
+
+ and use alias node defined by a previous node
+ with a corresponding anchor;
+ otherwise, a
+ loading-document-failed
+ error has been detected and processing is aborted.
- Although YAML-LD documents MAY include node anchors,
- documents MUST NOT use alias nodes.
+ The YAML-LD extended profile allows full use of
+ anchor names and alias nodes subject to
+ the requirements described above in this section.
- A YAML stream MUST include only a single YAML document,
- as the JSON-LD internal representation only supports
- a single document model.
-
- The YAML-LD extended profile
- extends the YAML Core Schema,
- allowing node tags to specify RDF literals
- by using a JSON-LD extended internal representation capable
- of directly representing RDF literals.
-
- As with the YAML-LD JSON profile,
- YAML-LD documents in the YAML-LD extended profile
- MUST NOT use encodings other than UTF-8.
-
- As with the YAML-LD JSON profile,
- keys used in a YAML mapping MUST be strings.
-
- YAML-LD docucments MAY use alias nodes,
- as long as dereferencing these aliases does not result in a loop.
+
+ If the {{JsonLdOptions/extendedYAML}} API flag is `true`, the processing result
+ will be in the extended internal representation.
- As with the YAML-LD JSON profile,
- a YAML stream MUST include only a single YAML document,
- as the JSON-LD extended internal representation only supports
- a single document model.
-
- Consier something like `!id` as a local tag to denote IRIs.
+
+ When processing using the YAML-LD JSON profile,
+ documents MUST NOT contain alias nodes;
+ otherwise, a
+ profile-error
+ error has been detected and processing is aborted.
YAML-LD processing is defined by converting YAML to the
+ internal representation and using [[[JSON-LD11-API]]]
+ to process on that representation,
+ after which the representation is converted back to YAML.
+ As information specific to a given YAML document structure is lost
+ in this transformation, much of the specifics of that
+ original representation are therefore lost in that conversion,
+ limiting the ability to fully round-trip a YAML-LD document back
+ to an equivalent representation.
+ Consequently, round-tripping in this context is limited to preservation of the semantic
+ representation of a document,
+ rather than a specific syntactic representation. The conversion process represented here is compatible with
+ the description of
+ "Composing the Representation Graph" from the
+ 3.1.2 Load section of [[YAML]].
+ The steps described below for converting to the
+ internal representation operate upon that
+ .
- In addition to maps, arrays, and strings,
- the internal representation allows native representation
- of numbers, boolean values, and nulls.
- The extended internal representation allows for native
- representation of RDF literals, both
- with a datatype IRI,
- and language-tagged strings.
+ When operating using the YAML-LD JSON profile,
+ it is intended that the common feature provided by most
+ YAML libraries of transforming YAML directly to JSON
+ satisfies the requirements for parsing a YAML-LD file.
- When transforming from the extended internal representation
- to the internal representation —
- for example when serializing to JSON
- or to the YAML-LD JSON profile —
- implementations MUST transform RDF literals to the closest
- native representation of the internal representation:
+
+ As a developer,
+ I want to be able to convert JSON-LD documents to YAML-LD by simply serializing the document using any
+ standard YAML library,
+ So that the resulting YAML is valid YAML-LD, resolving to the same graph as the original JSON-LD.
- An alternative would be to transform such literals to
- JSON-LD value objects,
- and we may want to provide a means of transforming between
- the internal representation
- and extended internal representation
- using value objects,
- but this treatment is consistent with
- [[YAML]] Core Schema
- Tag Resolution.
- A YAML stream is composed of zero or more YAML documents.
- This specification extends the [[[JSON-LD11-API]]] [[JSON-LD11-API]]
-
- Application Programming Interface
-
- and the [[[JSON-LD11-FRAMING]]] [[JSON-LD11-FRAMING]]
-
- Application Programming Interface
-
- to manage the serialization and deserialization of [[YAML]]
- and to enable an option for setting the
- YAML-LD extended profile.
-
+ YAML streams may correspond more directly to
+ [[[RFC7464]]], which are not presently part of the
+ JSON-LD representation model.
+ The description here more closely aligns with how JSON-LD
+ interprets HTML Scripts.
+
- The
- JSON-LD Processor
- interface is the high-level programming structure that developers
- use to access the JSON-LD transformation methods.
- The updates below is an experimental
- extension of the {{JsonLdProcessor}} interface defined in the
- JSON-LD 1.1 API [[JSON-LD11-API]]
- to serialize output as YAML rather than JSON.
-
+ Any error reported in a recursive processing step MUST result
+ in the failure of this processing step. From the YAML grammar,
+ a YAML document MAY be preceded by a
+ Document Prefix
+ and/or a set of
+ directives
+ followed by a
+ YAML bare document,
+ which is composed of a single node.
+ The {{JsonLdOptions}} type is used to pass various options to the
- {{JsonLdProcessor}} methods.
+ Any error reported in a recursive processing step MUST result
+ in the failure of this processing step.
- In addition to those options defined in the
- JSON-LD 1.1 API [[JSON-LD11-API]]
- and JSON-LD 1.1 Framing [[JSON-LD11-FRAMING]],
- this specification defines these additional options:
- Both block sequences and flow sequences
+ are directly aligned with
+ an array in the internal representation.
+ Any error reported in a recursive processing step MUST result
+ in the failure of this processing step. Both block mappings and flow mappings
+ are directly aligned with
+ a map in the internal representation.
+ Any error reported in a recursive processing step MUST result
+ in the failure of this processing step. This section describes an update to the
- built-in {{LoadDocumentCallback}}
- to load YAML streams and documents
- into the internal representation,
- or into the extended internal representation
- if the {{JsonLdOptions/extendedYAML}} API flag is `true`.
- The {{LoadDocumentCallback}} algorithm in [[JSON-LD11-API]]
- is updated as follows:
-
- These updates are intended to be compatible with other updates
- to the {{LoadDocumentCallback}}, such as
- Process HTML
- as defined in [[JSON-LD11-API]].
-
+ Implementations may retain the
+ representation as an YAML Integer,
+ or YAML Floating Point,
+ but a JSON-LD processor must treat them uniformly
+ as a number, although the specific type of number
+ value SHOULD be retained for round-tripping.
+ The YamlLdErrorCode represents the collection of valid YAML-LD error codes,
- which extends the {{JsonLdErrorCode}} definitions.
+ The conversion result is the value of the entry
+ in the |named nodes| map having the node entry.
+ If none exist, the document is invalid,
+ and processing MUST end in failure.
+
+ If an alias node is encountered when processing the
+ YAML representation graph
+ and the {{JsonLdOptions/extendedYAML}} flag is `false`,
+ the YAML-LD JSON profile has been selected.
+ A profile-error
+ error has been detected and processing MUST be aborted.
+
+ If a cycle is detected,
+ a processing error MUST be returned,
+ and processing aborted.
+ See Security considerations in JSON-LD 1.1.
- Also, see the YAML media type registration. The conversion process from the internal representation
+ involves turning that representation back into a YAML
+ representation graph
+ and relies on the description of
+ "Serializing the Representation Graph" from the
+ 3.1.1 Dump section of [[YAML]]
+ for the final serialization.
+
- For general interoperability considerations on the serialization of
- JSON documents in [[YAML]], see YAML
- and the Interoperability consideration of application/yaml [[I-D.ietf-httpapi-yaml-mediatypes]].
-
- The YAML-LD format and the media type registration are not restricted to a specific
- version of YAML,
- but implementers that want to use YAML-LD with YAML versions
- other than 1.2.2 need to be aware that the considerations and analysis provided
- here, including interoperability and security considerations, are based
- on the YAML 1.2.2 specification.
-
+ As the internal representation is rooted by either
+ an array or a map,
+ the process of transforming the internal representation
+ to YAML begins by preparing an empty representation graph
+ which will be rooted with either a
+ YAML mapping or YAML sequence.
+
+ Although outside of the scope of this specification,
+ processors MAY use
+ YAML directives, including TAG directives, and
+ Document markers,
+ as appropriate for best results.
+ Specifically, if the {{JsonLdOptions/extendedYAML}} API flag is `true`,
+ the document SHOULD use the `%YAML` directive with
+ version set to at least `1.2`.
+ To improve readability and reduce document size,
+ the document MAY use a `%TAG` directive appropriate for
+ RDF literals contained within the representation.
+ This section has been submitted to the Internet Engineering Steering
- Group (IESG) for review, approval, and registration with IANA.
- This section describes the information required to register the above media type according to [[RFC6838]]
-
+ The use of `%TAG` directives in YAML-LD is similar to the use
+ of the `PREFIX` directive in [[?Turtle]]
+ or the general use of terms as prefixes to create
+ Compact IRIs in [[JSON-LD11]]:
+ they not change the meaning of the encoded scalars.
+ A non-empty list of space-separated URIs identifying specific
- constraints or conventions that apply to a YAML-LD document according to [[RFC6906]].
- A profile does not change the semantics of the resource representation
- when processed without profile knowledge, so that clients both with
- and without knowledge of a profiled resource can safely use the same
- representation. The This specification allows the use of the `profile` parameters listed in
- and additionally defines the following:
-
- When used as a media type parameter [[RFC4288]]
- in an HTTP Accept header field [[RFC9110]],
- the value of the When processing the "profile" media type parameter, it is important to
- note that its value contains one or more URIs and not IRIs. In some cases
- it might therefore be necessary to convert between IRIs and URIs as specified in
- section 3 Relationship between IRIs and URIs
- of [[RFC3987]]. Fragment identifiers used with application/ld+yaml
- are treated as in RDF syntaxes, as per
- RDF 1.1 Concepts and Abstract Syntax
- [[RDF11-CONCEPTS]]
- and do not follow the process defined for application/yaml.
-
+ Although allowed within the YAML Grammar, some current YAML parsers
+ do not allow the use of `"#"` within a tag URI. Substituting
+ the `"%23"` escape is a workaround for this problem, that will
+ hopefully become unnecessary as implementations are updated.
+ A concrete proposal in that direction would be to use a tag at the
+ top-level of any "idiomatic" YAML-LD document, applying to the whole
+ object/array that makes the document. FIXME It might also include a version
+ to identify the specification that it relates to, allowing
+ for version announcement that could be used for future-proofing. REMOVE THIS SECTION BEFORE PUBLICATION. The following block is one example: See for an example
+ of serializing the extended internal representation. This section identifies two application profiles for operating with
+ YAML-LD: Application profiles allow publishers to use YAML-LD
+ either for maximum interoperability,
+ or for maximum expressivity.
+ The YAML-LD JSON profile provides for complete round-tripping
+ between YAML-LD documents and JSON-LD documents.
+ The YAML-LD extended profile allows for
+ fuller use of YAML features to enhance the ability to
+ represent a larger number of native datatypes
+ and reduce document redundancy. Application profiles can be set using the {{JsonLdProcessor}}
+ API interface, as well as an HTTP request profile (see ).
+ The YAML-LD JSON profile
+ is based on the YAML Core Schema,
+ which interprets only a limited set of node tags.
+ YAML scalars with node tags outside of the defined range
+ SHOULD be avoided and MUST be converted to the closest
+ scalar type from the YAML Core Schema,
+ if found.
+ See
+ for specifics.
+
+ Keys used in a YAML mapping MUST be strings.
+
+ Although YAML-LD documents MAY include node anchors,
+ documents MUST NOT use alias nodes.
+
+ A YAML stream MUST include only a single YAML document,
+ as the JSON-LD internal representation only supports
+ a single document model.
+
+ The YAML-LD extended profile
+ extends the YAML Core Schema,
+ allowing node tags to specify RDF literals
+ by using a JSON-LD extended internal representation capable
+ of directly representing RDF literals.
+
+ As with the YAML-LD JSON profile,
+ YAML-LD documents in the YAML-LD extended profile
+ MUST NOT use encodings other than UTF-8.
+
+ As with the YAML-LD JSON profile,
+ keys used in a YAML mapping MUST be strings.
+ Here, we propose to YAML-LD users a bit of advice which, although optional, might suggest one or two
- useful thoughts.
+ YAML-LD docucments MAY use alias nodes,
+ as long as dereferencing these aliases does not result in a loop.
+
- Follow JSON-LD best practices
- …in order to achieve a greater level of reusability, performance, and human friendliness among YAML-LD aware
- systems. The [[json-ld-bp]] document is as relevant to YAML-LD as it is to [[JSON-LD11]].
+
+ As with the YAML-LD JSON profile,
+ a YAML stream MUST include only a single YAML document,
+ as the JSON-LD extended internal representation only supports
+ a single document model.
- Do not force users to author contexts
+
+ Consier something like `!id` as a local tag to denote IRIs.
+ YAML-LD is intended to simplify the authoring of Linked Data for a wide range of domain experts; its target
- audience is not comprised solely of IT professionals. [[YAML]] is chosen as a medium to minimize syntactic noise,
- and to keep the authored documents concise and clear. [[JSON-LD11]] (and hence YAML-LD) Context comprises a special
- language of its own. A requirement to author such a context would make the domain expert's job much
- harder, which we, as system architects and developers, should try to avoid.
+ This specification defines
+ the
+ JSON-LD extended internal representation
+ , an extension
+ of the JSON-LD internal representation.
+
- Use a default context
-
+ In addition to maps, arrays, and strings,
+ the internal representation allows native representation
+ of numbers, boolean values, and nulls.
+ The extended internal representation allows for native
+ representation of RDF literals, both
+ with a datatype IRI,
+ and language-tagged strings.
+
+ When transforming from the extended internal representation
+ to the internal representation —
+ for example when serializing to JSON
+ or to the YAML-LD JSON profile —
+ implementations MUST transform RDF literals to the closest
+ native representation of the internal representation:
+ For instance, according to [[JSON-LD11-API]], the `expand()` method of a JSON-LD processor accepts an
- `expandContext` argument which can be used to provide a default system context.
+ An alternative would be to transform such literals to
+ JSON-LD value objects,
+ and we may want to provide a means of transforming between
+ the internal representation
+ and extended internal representation
+ using value objects,
+ but this treatment is consistent with
+ [[YAML]] Core Schema
+ Tag Resolution.
+
- Alias JSON-LD keywords
+
+ This specification extends the [[[JSON-LD11-API]]] [[JSON-LD11-API]]
+
+ Application Programming Interface
+
+ and the [[[JSON-LD11-FRAMING]]] [[JSON-LD11-FRAMING]]
+
+ Application Programming Interface
+
+ to manage the serialization and deserialization of [[YAML]]
+ and to enable an option for setting the
+ YAML-LD extended profile.
The `@` character is reserved in YAML, and thus requires quoting (or escaping), as in the following
- example:
+ The
+ JSON-LD Processor
+ interface is the high-level programming structure that developers
+ use to access the JSON-LD transformation methods.
+ The updates below is an experimental
+ extension of the {{JsonLdProcessor}} interface defined in the
+ JSON-LD 1.1 API [[JSON-LD11-API]]
+ to serialize output as YAML rather than JSON.
+ The {{JsonLdOptions}} type is used to pass various options to the
+ {{JsonLdProcessor}} methods. The need to quote these keywords has to be learnt, and introduces one more little irregularity to the document
- author's life. Further, on most keyboard layouts, typing quotes will require `Shift`, which reduces typing speed,
- albeit slightly.
+ In addition to those options defined in the
+ JSON-LD 1.1 API [[JSON-LD11-API]]
+ and JSON-LD 1.1 Framing [[JSON-LD11-FRAMING]],
+ this specification defines these additional options:
+ In order to avoid this, the context might introduce custom mappings for the necessary keywords. For instance,
- [[schema-org]] context redefines `@id` as just `id` — which seems to be much more convenient to type, and
- no more difficult to remember. This section describes an update to the
+ built-in {{LoadDocumentCallback}}
+ to load YAML streams and documents
+ into the internal representation,
+ or into the extended internal representation
+ if the {{JsonLdOptions/extendedYAML}} API flag is `true`.
+ The {{LoadDocumentCallback}} algorithm in [[JSON-LD11-API]]
+ is updated as follows:
+
- Use YAML-LD Convenience Context
- YAML-LD users may use a JSON-LD context provided as part of this specification, henceforth known as the
- convenience context, which defines a standardized mapping of every `@`-keyword to a `$`-keyword, except `@context`.
-
+ These updates are intended to be compatible with other updates
+ to the {{LoadDocumentCallback}}, such as
+ Process HTML
+ as defined in [[JSON-LD11-API]].
+ The convenience context contains an alias to every JSON-LD keyword which the JSON-LD 1.1
- specification permits aliasing — which means all the keywords except The YamlLdErrorCode represents the collection of valid YAML-LD error codes,
+ which extends the {{JsonLdErrorCode}} definitions. The applicability of this context depends on the domain and is left to the architect's best judgement.Fragment identifiers
+
-
+
+
-
-
-
- Converting a YAML sequence
-
-
-
-
- Examples
+ Converting a YAML mapping
-
-
-
+
-
- FAQ
- Converting a YAML scalar
+ #### Why does YAML-LD not preserve comments?
+
-
-
-
-
- Converting a YAML alias node
+
+
+
- Conversion to YAML
-
-
+
+
+
-
+ data-content-type="application/ld+yaml"
+ title="YAML-LD with references">
+
-
+
+
-
- !yaml-ld
- $context: http://schema.org/
- $type: Person
- name: Pierre-Antoine Champin
-
Best Practices
- Converting From the Internal Representation
+
-
-
-
+ Instead, provide pre-built contexts that the user can reference by URL for a majority of common use cases.
+
+
-
- Application Profiles
+
-
+
+
+
+
+ @context
. The reserved `@` character is
+ replaced by `$`, which is not reserved and therefore does not require quoting. Consider
+
+ reformatted using the convenience context:
+
+
- YAML-LD JSON Profile
+ Extended YAML-LD Profile
YAML-LD Extended Profile
-
- The JSON-LD Extended Internal Representation
+ Conversion to the Internal Representation
+
+
-
-
- Converting a YAML stream
- The Application Programming Interface
+ JsonLdProcessor
+
+
-
+
+ Converting a YAML document
+
+
-
-
- Otherwise, if both the {{JsonLdOptions/useNativeTypes}}
- and {{JsonLdOptions/extendedYAML}} flags are set
- and the
- datatype IRI
- of |value| is not `xsd:string`:
-
-
-
+
+
+
-
-
-
- JsonLdOptions
-
- partial dictionary JsonLdOptions {
- boolean extendedYAML = false;
- };
-
+ Converting a YAML sequence
-
-
-
-
+
-
Converting a YAML mapping
+
+
+
+
Remote Document and Context Retrieval
+ Converting a YAML scalar
-
+
-
+
+
-
-
- YamlLdErrorCode
- Converting a YAML alias node
-
- enum YamlLdErrorCode {
- "invalid-encoding",
- "mapping-key-error",
- "profile-error"
- };
-
+
-
- Security Considerations
+ Conversion to YAML
- Interoperability Considerations
+ IANA Considerations
+ application/ld+yaml
-
-
-
-
- profile
profile
parameter MAY be used by
- clients to express their preferences in the content negotiation process.
- If the profile parameter is given, a server SHOULD return a document that
- honors the profiles in the list which it recognizes,
- and MUST ignore the profiles in the list which it does not recognize.
- It is RECOMMENDED that profile URIs are dereferenceable and provide
- useful documentation at that URI. For more information and background
- please refer to [[RFC6906]].
-
- http://www.w3.org/ns/json-ld#extended
profile
parameter MUST be enclosed in quotes ("
) if it contains
- special characters such as whitespace, which is required when multiple profile URIs are combined.
-
-
+
+
- Fragment identifiers
- Examples
- FAQ
+
+ !yaml-ld
+ $context: http://schema.org/
+ $type: Person
+ name: Pierre-Antoine Champin
+
+ Converting From the Internal Representation
-
-
-
+
+
+
+
+ Application Profiles
-
-
-
-
+
- #### Why does YAML-LD not extend the JSON-LD data model ?
- YAML-LD JSON Profile
+
+
-
-
+
-
-
+ YAML-LD Extended Profile
- Since all these implementations pre-date this
- specification, some more interoperable choices include the following:
+ Best Practices
+ The JSON-LD Extended Internal Representation
-
+
+
+ The Application Programming Interface
- If possible, map JSON-LD keywords containing the `@` character to keywords that do not contain it.
+ JsonLdProcessor
+
+
-
+
+
+
+ Otherwise, if both the {{JsonLdOptions/useNativeTypes}}
+ and {{JsonLdOptions/extendedYAML}} flags are set
+ and the
+ datatype IRI
+ of |value| is not `xsd:string`:
+
+
+
+
+
+
+
+ JsonLdOptions
+
+ partial dictionary JsonLdOptions {
+ boolean extendedYAML = false;
+ };
-
+
+
+
+
+
+ Remote Document and Context Retrieval
+
+
+
-
+ @context
. The reserved `@` character is
- replaced by `$`, which is not reserved and therefore does not require quoting. Consider
-
- reformatted using the convenience context:YamlLdErrorCode
+
-
+
+ enum YamlLdErrorCode {
+ "invalid-encoding",
+ "mapping-key-error",
+ "profile-error"
+ };
-
+
+