Add back list processing to syntax and API specs.
authorGregg Kellogg <gregg@kellogg-assoc.com>
Thu, 20 Oct 2011 16:52:00 -0700
changeset 228 f0eb9266aeb4
parent 225 412de64fe08d
child 229 ce16d57ea9ca
Add back list processing to syntax and API specs.
spec/latest/json-ld-api/index.html
spec/latest/json-ld-syntax/index.html
--- a/spec/latest/json-ld-api/index.html	Sun Oct 16 18:57:13 2011 -0400
+++ b/spec/latest/json-ld-api/index.html	Thu Oct 20 16:52:00 2011 -0700
@@ -955,6 +955,8 @@
 </ol>
 </section>
 
+<p class="issue">What are the implications for expanding lists?</p>
+
 </section>
 
 <section>
@@ -986,6 +988,8 @@
 </ol>
 </section>
 
+<p class="issue">What are the implications for compacting lists?</p>
+
 </section>
 
 
@@ -1182,6 +1186,8 @@
 
 </section>
 
+<p class="issue">What are the implications for framing lists?</p>
+
 </section>
 
 <section>
@@ -2341,6 +2347,10 @@
             </li>
           </ol>
         </li>
+        <li>
+          If the <tref>JSON object</tref> has a <code>@list</code> key and the value is an <tref>array</tref>
+          process the value as a list starting at <a href="#processing-step-list">Step 4</a>.
+        </li>
         <li id="processing-step-subject">If the <tref>JSON object</tref> has a <code>@subject</code> key:
           <ol class="algorithm">
             <li>
@@ -2350,10 +2360,20 @@
               <tref>active object</tref>. Set the <tref>active subject</tref> to the <tref>active object</tref>.
             </li>
             <li>
-              Create a new <tref>processor state</tref> using copies of the <tref>active context</tref>,
-              <tref>active subject</tref> and <tref>active property</tref> and process the value
-              starting at <a href="#processing-step-associative">Step 2</a>, set the <tref>active
-              subject</tref> to the result and proceed using the previous <tref>processor state</tref>.
+              Create a new <tref>processor state</tref> copies of the <tref>active context</tref>,
+              <tref>active subject</tref> and <tref>active property</tref>.
+              <ol class="algorithm">
+                <li>
+                  If the <tref>active property</tref> is the target of a <code>@list</code> coercion,
+                  and the value is an <tref>array</tref>,
+                  process the value as a list starting at <a href="#processing-step-list">Step 4</a>.
+                </li>
+                <li>
+                  Otherwise, process the value starting at
+                  <a href="#processing-step-associative">Step 2</a>.
+                </li>
+                <li>Proceed using the previous <tref>processor state</tref>.</li>
+              </ol>
             </li>
           </ol>
         </li>
@@ -2402,6 +2422,31 @@
       </ol>
     </li>
 
+    <li id="processing-step-list">
+      Generate an RDF List by linking
+      each element of the list using <code>rdf:first</code> and <code>rdf:next</code>, terminating the list with <code>rdf:nil</code>
+      using the following sequence:
+      <ol class="algorithm">
+        <li>
+          If the list has no element, generate a triple using the <tref>active subject</tref>, <tref>active property</tref>
+          and <code>rdf:nil</code>.
+        </li>
+        <li>
+          Otherwise, generate a triple using using the <tref>active subject</tref>, <tref>active property</tref>
+          and a newly generated BNode identified as <em>first <tdef>blank node identifier</tdef></em>.
+        </li>
+        <li>
+          For each element other than the last element in the list:
+          <ol class="algorithm">
+            <li>Create a processor state using the active context, <em>first <tdef>blank node identifier</tdef></em> as the <tref>active subject</tref>, and <code>rdf:first</code> as the <tref>active property</tref>.</li>
+            <li>Unless this is the last element in the list, generate a new BNode identified as <em>rest <tdef>blank node identifier</tdef></em>, otherwise use <code>rdf:nil</code>.</li>
+            <li>Generate a new triple using <em>first <tdef>blank node identifier</tdef></em>, <code>rdf:rest</code> and <em>rest <tdef>blank node identifier</tdef></em>.</li>
+            <li>Set <em>first <tdef>blank node identifier</tdef></em> to <em>rest <tdef>blank node identifier</tdef></em>.</li>
+          </ol>
+        </li>
+      </ol>
+    </li>
+
     <li>
       If a <tref>string</tref> is detected:
       <ol class="algorithm">
--- a/spec/latest/json-ld-syntax/index.html	Sun Oct 16 18:57:13 2011 -0400
+++ b/spec/latest/json-ld-syntax/index.html	Thu Oct 20 16:52:00 2011 -0700
@@ -1695,6 +1695,92 @@
 </section>
 
 <section>
+  <h2>Lists</h2>
+  <p>
+    Because graphs do not describe ordering for links between nodes,  in contrast to plain JSON, multi-valued properties
+    in JSON-LD do not provide an ordering of the listed objects. For example, consider the following
+    simple document:
+  </p>
+  <pre class="example" data-transform="updateExample">
+  <!--
+  {
+  ...
+    "@subject": "http://example.org/people#joebob",
+    "nick": ****["joe", "bob", "jaybee"]****,
+  ...
+  }
+  -->
+  </pre>
+  <p>
+    This results in three triples being generated, each relating the subject to an individual
+    object, with no inherent order.</p>
+  <p>To preserve the order of the objects, RDF-based languages, such as [[TURTLE]]
+    use the concept of an <code>rdf:List</code> (as described in [[RDF-SCHEMA]]). This uses a sequence
+    of unlabeled nodes with properties describing a value, a null-terminated next property. Without
+    specific syntactical support, this could be represented in JSON-LD as follows:
+  </p>
+  <pre class="example" data-transform="updateExample">
+  <!--
+  {
+  ...
+    "@subject": "http://example.org/people#joebob",
+    "nick": ****{****,
+      ****"@first": "joe"****,
+      ****"@rest": {****
+        ****"@first": "bob"****,
+        ****"@rest": {****
+          ****"@first": "jaybee"****,
+          ****"@rest": "@nil"****
+          ****}****
+        ****}****
+      ****}****
+    ****}****,
+  ...
+  }
+  -->
+  </pre>
+  <p>
+    As this notation is rather unwieldy and the notion of ordered collections is rather important
+    in data modeling, it is useful to have specific language support. In JSON-LD, a list may
+    be represented using the <code>@list</code> keyword as follows:
+  </p>
+  <pre class="example" data-transform="updateExample">
+  <!--
+  {
+  ...
+    "@subject": "http://example.org/people#joebob",
+    "foaf:nick": ****{"@list": ["joe", "bob", "jaybee"]}****,
+  ...
+  }
+  -->
+  </pre>
+  <p>
+    This describes the use of this <tref>array</tref> as being ordered, and order is maintained through
+    normalization and RDF conversion. If every use of a given multi-valued property is a
+    list, this may be abbreviated by adding an <code>@coerce</code> term:
+  </p>
+  <pre class="example" data-transform="updateExample">
+  <!--
+  {
+    ****"@context": {****
+      ...
+      ****"@coerce": {****
+        ****"@list": ["foaf:nick"]****
+      ****}****
+    ****}****,
+  ...
+    "@subject": "http://example.org/people#joebob",
+    "foaf:nick": ****["joe", "bob", "jaybee"]****,
+  ...
+  }
+  -->
+  </pre>
+  <p>
+    The @list keyword can be used within the <code>@coerce</code> section of a <code>@context</code> to
+    cause value arrays to be coerced into an ordered list.
+  </p>
+</section>
+<section>
 <h2>Normalization</h2>
 
 <p>Normalization is the process of taking <tref>JSON-LD input</tref> and