From 618258b509fedb02357a1c038595c05709893b84 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 4 Aug 2018 17:39:34 -0700 Subject: [PATCH 1/4] Describe lists containing lists, as motivated by GeoJSON. Fixes #36. --- index.html | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 9738ecde..c336a0f7 100644 --- a/index.html +++ b/index.html @@ -26,13 +26,13 @@ prevVersion: "https://www.w3.org/TR/2014/REC-json-ld-20140116/", previousPublishDate: "2014-01-16", previousMaturity: "REC", + github: "https://github.com/w3c/json-ld-syntax/", // if there a publicly available Editor's Draft, this is the link edDraftURI: "https://w3c.github.io/json-ld/", includePermalinks: true, doJsonLd: true, - testSuiteURIkey: "https://json-ld.org/test-suite/", postProcess: [internalizeTermListReferences], // if you want to have extra CSS, append them to this list @@ -95,8 +95,6 @@ note: "v1.0" } ], - github: "https://github.com/w3c/json-ld-syntax/", - // name of the WG wg: "JSON-LD Working Group", @@ -2301,9 +2299,141 @@

Sets and Lists

--> -

List of lists in the form of list objects - are not allowed in this version of JSON-LD. This decision was made due to the - extreme amount of added complexity when processing lists of lists.

+

The implementation of lists in RDF depends on linking anonymous nodes together using the properties rdf:first and rdf:rest, with the end of the list defined as the resource rdf:nil. This can be represented as triples, as the following example shows, but the results are somewhat unwieldy.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SubjectPropertyValue
http://example.org/people#joebobfoaf:nick_:b0
_:b0rdf:firstjoe
_:b0rdf:rest_:b1
_:b1rdf:firstbob
_:b1rdf:rest_:b2
_:b2rdf:firstjaybee
_:b2rdf:restrdf:nil
+ +

Consequently, most RDF serializations (including JSON-LD) provide a syntactic shortcut for these lists. In Turtle, the graph would be expressed as follows:

+ +
+
+
+ +

In JSON-LD 1.1, lists of lists, where the value of a list object, may itself be a list object recusively, are fully supported. For example, in GeoJSON (see [[RFC7946]]), coordinates are an ordered list of positions, which are represented as an array of two or more numbers. For example:

+ +
+{
+  "type": "Feature",
+  "bbox": [-10.0, -10.0, 10.0, 10.0],
+  "geometry": {
+    "type": "Polygon",
+    "coordinates": [
+        [
+            [-10.0, -10.0],
+            [10.0, -10.0],
+            [10.0, 10.0],
+            [-10.0, -10.0]
+        ]
+    ]
+  }
+  //...
+}
+
+ +

For this example, it's important that the values expressed within coordinates maintain their order, which requires the use of embedded list structures. In JSON-LD 1.1, we can express this using recursive lists, by simply adding the appropriate context definion:

+ +
+{
+  "@context": {
+    "@vocab": "https://purl.org/geojson/vocab#",
+    "type": "@type",
+    "bbox": {"@container": "@list"},
+    "coordinates": {"@container": "@list"}
+  },
+  "type": "Feature",
+  "bbox": [-10.0, -10.0, 10.0, 10.0],
+  "geometry": {
+    "type": "Polygon",
+    "coordinates": [
+        [
+            [-10.0, -10.0],
+            [10.0, -10.0],
+            [10.0, 10.0],
+            [-10.0, -10.0]
+        ]
+    ]
+  }
+  ####//...####
+}
+
+ +

Note that coordinates includes three levels of lists. When expressed in Turtle, this would be the following:

+ +
+@prefix geojson: .
+
+[
+  a geojson:Feature ;
+  geojson:bbox (-10.0 -10.0 10.0 10.0) ;
+  geojson:geometry [
+    a geojson:Polygon ;
+    geojson:coordinates (
+      (
+        (-10.0 -10.0)
+        (10.0 -10.0)
+        (10.0 10.0)
+        (-10.0 -10.0)
+      )
+    )
+  ]
+] .
+

While @list is used to describe ordered lists, the @set keyword is used to describe unordered sets. @@ -5118,6 +5248,7 @@

Changes since 1.0 Recommendation of 16 January 2014

a context. When this is set, vocabulary-relative IRIs, such as the keys of node objects, are expanded or compacted relative to the base IRI using string concatenation. +
  • Lists may now have members which are themselves lists.
  • From 30adecdbb50a7de509d099a725e6360fbfb6be46 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 4 Aug 2018 17:49:47 -0700 Subject: [PATCH 2/4] Fix turtle syntax. --- index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index c336a0f7..a89ffd58 100644 --- a/index.html +++ b/index.html @@ -2354,7 +2354,7 @@

    Sets and Lists

    @@ -2416,6 +2416,7 @@

    Sets and Lists

    +
     

    While @list is used to describe ordered lists, From 31d1804b7ff7c3fd34eac5489b12caecad4258dd Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sun, 5 Aug 2018 12:07:16 -0700 Subject: [PATCH 3/4] Factor in @iherman's comments, and include an example of recursive lists in expanded form. --- index.html | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index a89ffd58..fbecb44a 100644 --- a/index.html +++ b/index.html @@ -2299,7 +2299,11 @@

    Sets and Lists

    --> -

    The implementation of lists in RDF depends on linking anonymous nodes together using the properties rdf:first and rdf:rest, with the end of the list defined as the resource rdf:nil. This can be represented as triples, as the following example shows, but the results are somewhat unwieldy.

    +

    The implementation of lists in RDF depends on linking anonymous nodes + together using the properties rdf:first and + rdf:rest, with the end of the list defined as the resource + rdf:nil. This can be represented as triples, as the following + example shows:

    @@ -2346,7 +2350,7 @@

    Sets and Lists

    -

    Consequently, most RDF serializations (including JSON-LD) provide a syntactic shortcut for these lists. In Turtle, the graph would be expressed as follows:

    +

    JSON-LD provides a syntactic shortcut for these lists. In Turtle, the graph would be expressed as follows:

    Sets and Lists
     -->
     
    -

    In JSON-LD 1.1, lists of lists, where the value of a list object, may itself be a list object recusively, are fully supported. For example, in GeoJSON (see [[RFC7946]]), coordinates are an ordered list of positions, which are represented as an array of two or more numbers. For example:

    +

    In JSON-LD 1.1, lists of lists, where the value of + a list object, may itself be a list object recusively, are + fully supported. For example, in GeoJSON (see [[RFC7946]]), + coordinates are an ordered list of positions, which are + represented as an array of two or more numbers. For example:

    Sets and Lists
     }
     
    -

    For this example, it's important that the values expressed within coordinates maintain their order, which requires the use of embedded list structures. In JSON-LD 1.1, we can express this using recursive lists, by simply adding the appropriate context definion:

    +

    For this example, it's important that the values + expressed within coordinates maintain their order, which requires the use of + embedded list structures. In JSON-LD 1.1, we can express this using recursive + lists, by simply adding the appropriate context definion:

    Sets and Lists
     }
     
    -

    Note that coordinates includes three levels of lists. When expressed in Turtle, this would be the following:

    +

    This is equivalent to the expanded form, which uses list objects:

    + +
    +[{
    +  "@type": ["https://purl.org/geojson/vocab#Feature"],
    +  "https://purl.org/geojson/vocab#bbox": [{
    +    "@list": [
    +      {"@value": -10.0},
    +      {"@value": -10.0},
    +      {"@value": 10.0},
    +      {"@value": 10.0}
    +    ]
    +  }],
    +  "https://purl.org/geojson/vocab#geometry": [{
    +    "@type": ["https://purl.org/geojson/vocab#Polygon"],
    +    "https://purl.org/geojson/vocab#coordinates": [{
    +      "@list": [{
    +        "@list": [
    +          {"@list": [{"@value": -10.0}, {"@value": -10.0}]},
    +          {"@list": [{"@value": 10.0}, {"@value": -10.0}]},
    +          {"@list": [{"@value": 10.0}, {"@value": 10.0}]},
    +          {"@list": [{"@value": -10.0}, {"@value": -10.0}]}
    +        ]
    +      }]
    +    }]
    +  }]
    +}]
    +
    + +

    Note that coordinates includes three levels of lists. + When expressed in Turtle, this would be the following:

    Date: Sat, 11 Aug 2018 14:48:35 -0700
    Subject: [PATCH 4/4] Address comments from @simonstey.
    
    ---
     index.html | 15 ++++++++-------
     1 file changed, 8 insertions(+), 7 deletions(-)
    
    diff --git a/index.html b/index.html
    index fbecb44a..ff39e7ed 100644
    --- a/index.html
    +++ b/index.html
    @@ -2363,10 +2363,10 @@ 

    Sets and Lists

    In JSON-LD 1.1, lists of lists, where the value of - a list object, may itself be a list object recusively, are + a list object, may itself be a list object, are fully supported. For example, in GeoJSON (see [[RFC7946]]), coordinates are an ordered list of positions, which are - represented as an array of two or more numbers. For example:

    + represented as an array of two or more numbers:

    Sets and Lists
     }
     
    -

    For this example, it's important that the values - expressed within coordinates maintain their order, which requires the use of - embedded list structures. In JSON-LD 1.1, we can express this using recursive - lists, by simply adding the appropriate context definion:

    +

    For these examples, it's important that values + expressed within bbox and coordinates maintain their order, + which requires the use of embedded list structures. In JSON-LD 1.1, we can + express this using recursive lists, by simply adding the appropriate context + definion:

    Sets and Lists
     }]
     
    -

    Note that coordinates includes three levels of lists. +

    Note that coordinates includes three levels of lists. When expressed in Turtle, this would be the following: