From 12c79589b7f5e5ef82f4b6d2ac2fc67caa05ae88 Mon Sep 17 00:00:00 2001
From: Gregg Kellogg Using the Serialize RDF as JSON-LD algorithm
+ Using the Serialize RDF as JSON-LD Algorithm
a developer could transform this document into expanded JSON-LD: The example above is the JSON-LD serialization of the output of the
- Serialize RDF as JSON-LD algorithm,
+ Serialize RDF as JSON-LD Algorithm,
where the algorithm's use of dictionaries are replaced with JSON objects. Note that the output above could easily be compacted using the technique outlined
in the previous section. It is also possible to deserialize the JSON-LD document back
- to RDF using the Deserialize JSON-LD to RDF algorithm.RDF Serialization/Deserialization
-->
- RDF Serialization/Deserialization
This algorithm deserializes a JSON-LD document to an RDF dataset. Please note that RDF does not allow a blank node to be used @@ -3843,8 +3843,10 @@
The algorithm takes a JSON-LD document element and returns an - RDF dataset. Unless the produceGeneralizedRdf option +
The algorithm takes a dictionary node map, which
+ is the result of the Node Map Generation algorithm and
+ an RDF dataset dataset into which new graphs and triples are added.
+ Unless the produceGeneralizedRdf option
is set to true
, RDF triple
containing a blank node predicate
are excluded from output.
0
.
@default
, set
+ set triples to the value of the defaultGraph
+ attribute of dataset.
+ Otherwise, initialize graph as an empty RdfGraph
+ and add to dataset using its
+ add method along with graph name
+ for graphName.@type
, then for each
- type in values, append a triple
- composed of subject, rdf:type
,
- and type to triples.
- unless type is not well-formed.rdf:type
for predicate,
+ and type for object
+ and add to triples
+ using its add method,
+ unless type is not well-formed.null
, indicating a
non-well-formed RDF resource
that has to be ignored.@default
, add
- triples to the default graph in dataset.This algorithm serializes an RDF dataset consisting of a @@ -4095,7 +4097,7 @@
true
,
+ If the useNativeTypes flag is set to true
,
RDF literals with a
datatype IRI
that equals xsd:integer
or xsd:double
are converted
@@ -4106,20 +4108,24 @@ rdf:type
flag is set to true, rdf:type
+ Unless the useRdfType flag is set to true, rdf:type
predicates will be serialized as @type
as long as the associated object is
either an IRI or blank node identifier.
The algorithm takes one required and three optional inputs: an RDF dataset dataset
- and the three flags use native types, use rdf:type
,
+ and the three flags useNativeTypes, useRdfType,
and the ordered flag, used to order
dictionary member keys lexicographically, where noted
that all default to false
.
The dataset is iterable to iterate over graphs and graph names + contained within the RdfDataset. Each graph is also iterable + for iterating over triples contained within the RdfGraph.
+@id
whose value is
set to object.rdf:type
, the
- use rdf:type
flag is not true
, and object
+ useRdfType flag is not true
, and object
is an IRI or blank node identifier,
append object to the value of the @type
member of node; unless such an item already exists.
@@ -4165,7 +4171,7 @@ @type
member whose value is an array with a single item equal to
rdf:List
,
- node represents a well-formed list node.
+ node represents a well-formed list node.
Perform the following steps to traverse the list backwards towards its head:
rdf:first
member of
@@ -4296,7 +4302,7 @@ true
,
+ If the useNativeTypes flag is set to true
,
RDF literals with a
datatype IRI
that equals xsd:integer
or xsd:double
are converted
@@ -4313,7 +4319,7 @@ This algorithm takes two required inputs: a value to be converted - to a dictionary and a flag use native types.
+ to a dictionary and a flag useNativeTypes.null
true
+ true
To ensure lossless round-tripping the
- Serialize RDF as JSON-LD algorithm
- specifies a use native types flag which controls whether
+ Serialize RDF as JSON-LD Algorithm
+ specifies a useNativeTypes flag which controls whether
RDF literals
with a datatype IRI
equal to xsd:integer
, xsd:double
, or
xsd:boolean
are converted to their JSON-native
- counterparts. If the use native types flag is set to
+ counterparts. If the useNativeTypes flag is set to
false
, all literals remain in their original string
representation.
- [Constructor] interface JsonLdProcessor { static Promise<JsonLdDictionary> compact( JsonLdInput input, @@ -4521,11 +4525,17 @@The JsonLdProcessor Interface
JsonLdInput input, optional JsonLdContext? context, optional JsonLdOptions? options); + static Promise<sequence<JsonLdDictionary>> fromRdf( + RdfDataset input, + optional JsonLdOptions? options); + static Promise<RdfDataset> toRdf( + JsonLdInput input, + optional JsonLdOptions? options); };
Compacts the given input using the context according to the steps in the @@ -4636,7 +4646,7 @@
false
.
+ with ordered set to false
.@context
member, set
context to that member's value, otherwise to context.null
.0
)
- to be used by the
- Generate Blank Node Identifier algorithm.null
is passed, the result will not be compacted
but kept in expanded form.
Transforms the given input into + a JSON-LD document in expanded form + according to the steps in the Serialize RDF as JSON-LD Algorithm:
+ +This interface does not define a means of creating + an RdfDataset from an arbitrary input, other than the + toRdf method.
+ +Transforms the given input into an RdfDataset + according to the steps in the Deserialize JSON-LD to RDF Algorithm:
+ +The JsonLdContext type is used to refer to a value that that may be a dictionary, a string representing an IRI, or an array of dictionaries and strings.
-The RdfDataset interface describes operations on an RDF dataset used by the fromRdf and toRdf methods in the JsonLdProcessor interface. The interface may be used for constructing a new RDF dataset, which has a default graph accessible via the defaultGraph attribute.
+ ++ [Constructor] + interface RdfDataset { + readonly attribute RdfGraph defaultGraph; + void add(USVString graphName, RdfGraph graph); + iterable<USVString?, RdfGraph>; + }; ++ +
Adds an RdfGraph and its associated graph name to the RdfDataset. Used by the Deserialize JSON-LD to RDF Algorithm.
+ +null
(for the default
+ graph), an IRI or blank node identifier and graph an
+ RdfGraph instance.The RdfGraph interface describes operations on an RDF graph used by the fromRdf and toRdf methods in the JsonLdProcessor interface. The interface may be used for constructing a new RDF graph, which is composed of zero or more RdfTriple instances.
+ ++ [Constructor] + interface RdfGraph { + void add(RdfTriple triple); + iterable<RdfTriple>; + }; ++ +
Adds an RdfTriple to the RdfGraph. Used by the Deserialize JSON-LD to RDF Algorithm.
+ +The RdfTriple interface describes an RDF Triple.
+ ++ [Constructor] + interface RdfTriple { + readonly attribute USVString subject; + readonly attribute USVString predicate; + readonly attribute (USVString or RdfLiteral) object; + }; ++ +
The RdfLiteral interface describes an RDF Literal.
+ ++ [Constructor] + interface RdfLiteral { + readonly attribute USVString value; + readonly attribute USVString datatype; + readonly attribute USVString? language; + }; ++ +
rdf:langString
, language MUST be specified.rdf:langString
true
, the JSON-LD processor may emit blank nodes for
- triple predicates, otherwise they will be omitted.json-ld-1.0
or json-ld-1.1
, the
@@ -4777,6 +4971,11 @@ rdf:type
properties to be kept as IRIs in the output, rather than use @type
.true
, certain algorithm
processing steps where indicated are ordered lexicographically.
@@ -5130,7 +5329,7 @@