Update frame algorithm to specify that subjects and properties are processed in order.
authorGregg Kellogg <gregg@kellogg-assoc.com>
Sat, 21 Apr 2012 12:31:56 -0700
changeset 560 3a78d3cda32f
parent 559 dc6b0ba407b1
child 561 2e5a95a341d4
Update frame algorithm to specify that subjects and properties are processed in order.
Update frame-0012 and frame-0013 to use this defined order.
spec/latest/json-ld-api/index.html
test-suite/tests/frame-0012-out.jsonld
test-suite/tests/frame-0013-out.jsonld
--- a/spec/latest/json-ld-api/index.html	Sat Apr 21 01:49:17 2012 -0400
+++ b/spec/latest/json-ld-api/index.html	Sat Apr 21 12:31:56 2012 -0700
@@ -1108,7 +1108,7 @@
     <tref>term</tref>s specified in the <tref>active context</tref> using an optional <em>value</em>.</p>
 
 <section>
-  <h3>Algorithm</h3>
+  <h3>IRI Compaction Algorithm</h3>
   <p>The algorithm for generating a <tref>compact IRI</tref> is:
     <ol class="algorithm">
       <li>If <em>iri</em> is <code>rdf:type</code>, return <code>@type</code>.</li>
@@ -1679,7 +1679,7 @@
   <li>Get values for <em>embedOn</em> and <em>explicitOn</em> by looking in <em>frame</em>
     for the keys <code>@embed</code> and <code>@explicit</code> using the current values
     for <tref>object embed flag</tref> and <tref>explicit inclusion flag</tref> from <em>state</em> if not found.</li>
-  <li>For each <em>id</em> and <em>subject</em> from the set of matched subjects:
+  <li>For each <em>id</em> and <em>subject</em> from the set of matched subjects, ordered by <em>id</em>:
     <ol class="algorithm">
       <li>If the <tref>active property</tref> is <tref>null</tref>, set the <tref>map of embeds</tref> in
         <em>state</em> to an empty map.</li>
@@ -1710,7 +1710,8 @@
       <li>Otherwise:
         <ol class="algorithm">
           <li>Add <em>embed</em> to <tref>map of embeds</tref> for <em>id</em>.</li>
-          <li>Process each <em>property</em> and <em>value</em> in the matched <em>subject</em> as follows:
+          <li>Process each <em>property</em> and <em>value</em> in the matched <em>subject</em>, ordered
+            by <em>property</em>:
             <ol class="algorithm">
               <li>If <em>property</em> is a <tref>keyword</tref>, add <em>property</em> and a copy of <em>value</em>
                 to <em>output</em> and continue with the next property from <em>subject</em>.</li>
@@ -1732,7 +1733,8 @@
                       <li>If <em>listitem</em> is a <tref>subject reference</tref>
                         process <em>listitem</em> recursively using this algorithm passing a new map of
                         <em>subjects</em> that contains the <code>@id</code> of <em>listitem</em> as the key
-                        and the <tref>subject reference</tref> as the value. Pass the first value from
+                        and the <tref>subject definition</tref> from the original <tref>map of flattened subjects</tref>
+                        as the value. Pass the first value from
                         <em>frame</em> for <em>property</em> as <em>frame</em>, <em>list</em>
                         as <em>parent</em>, and <code>@list</code> as <tref>active property</tref>.</li>
                       <li>Otherwise, append a copy of <em>listitem</em> to <code>@list</code> in <em>list</em>.</li>
@@ -1741,7 +1743,8 @@
                   <li>If <em>item</em> is a <tref>subject reference</tref>
                     process <em>item</em> recursively using this algorithm passing a new map as
                     <em>subjects</em> that contains the <code>@id</code> of <em>item</em> as the key and
-                    the <tref>subject reference</tref> as the value. Pass the first value from
+                    the <tref>subject definition</tref> from the original <tref>map of flattened subjects</tref>
+                    as the value. Pass the first value from
                     <em>frame</em> for <em>property</em> as <em>frame</em>, <em>output</em>
                     as <em>parent</em>, and <em>property</em> as <tref>active property</tref>.
                   <div class="issue">Passing a <tref>subject reference</tref> doesn't work if this map
@@ -1754,7 +1757,7 @@
             </ol>
           </li>
           <li>Process each <em>property</em> and <em>value</em> in <em>frame</em>,
-            where <em>property</em> is not a <em>keyword</em>, as follows:
+            where <em>property</em> is not a <em>keyword</em>, ordered by <em>property</em>:
             <ol class="algorithm">
               <li>Set <em>property frame</em> to the first item in <em>value</em> or a newly created
                 <tref>JSON object</tref> if <em>value</em> is empty.</li>
--- a/test-suite/tests/frame-0012-out.jsonld	Sat Apr 21 01:49:17 2012 -0400
+++ b/test-suite/tests/frame-0012-out.jsonld	Sat Apr 21 12:31:56 2012 -0700
@@ -3,18 +3,18 @@
     "sp": "http://smartplatforms.org/terms#"
   },
   "@graph": [{
+    "@id": "http://example.org/fill-1",
+    "@type": "sp:Fulfillment",
+    "sp:hasMedication": {
+      "@id": "http://example.org/med-1"
+    },
+    "sp:label": "30 pills on 2/2/2011"
+  }, {
     "@id": "http://example.org/med-1",
     "@type": "sp:Medication",
     "sp:hasFulfillment": {
       "@id": "http://example.org/fill-1"
     },
     "sp:label": "Lisinopril"
-  }, {
-    "@id": "http://example.org/fill-1",
-    "@type": "sp:Fulfillment",
-    "sp:hasMedication": {
-      "@id": "http://example.org/med-1"
-    },
-    "sp:label": "30 pills on 2/2/2011"
   }]
 }
\ No newline at end of file
--- a/test-suite/tests/frame-0013-out.jsonld	Sat Apr 21 01:49:17 2012 -0400
+++ b/test-suite/tests/frame-0013-out.jsonld	Sat Apr 21 12:31:56 2012 -0700
@@ -3,6 +3,8 @@
     "ex": "http://example.org/"
   },
   "@graph": [{
+    "@id": "ex:forgotten"
+  }, {
     "@id": "ex:looker",
     "ex:canSee": [
       {
@@ -13,8 +15,6 @@
       }
     ]
   }, {
-    "@id": "ex:forgotten"
-  }, {
     "@id": "ex:spotted"
   }]
 }
\ No newline at end of file