Merge branch 'master' of github.com:json-ld/json-ld.org
authorDave Longley <dlongley@digitalbazaar.com>
Thu, 12 Apr 2012 14:48:13 -0400
changeset 508 16e640f2ef19
parent 502 f44db14e8ad4 (current diff)
parent 507 923e73e89b65 (diff)
child 509 f101d7de2d1b
Merge branch 'master' of github.com:json-ld/json-ld.org
--- a/spec/latest/json-ld-api/index.html	Thu Apr 12 14:48:00 2012 -0400
+++ b/spec/latest/json-ld-api/index.html	Thu Apr 12 14:48:13 2012 -0400
@@ -1841,9 +1841,10 @@
 <section>
   <h4>RDF Conversion Algorithm Terms</h4>
   <dl>
-    <dt><tdef>default graph</tdef></dt>
+    <dt><tdef>graph name</tdef></dt>
     <dd>
-      the destination graph for all <a>Statement</a>s (triples or quads) generated by JSON-LD markup.
+      A <tref>IRI</tref> or <tref>Blank Node</tref> used to identify statements belonging to a
+      <em>named graph</em>.
     </dd>
   </dl>
 </section>
@@ -1855,127 +1856,103 @@
   </p>
   <p>
     A conforming JSON-LD processor implementing RDF conversion MUST implement a
-    processing algorithm that results in the same <tref>default graph</tref> that the following
+    processing algorithm that results in the same set of RDF <a>Statement</a>s that the following
     algorithm generates:
   </p>
 
-  <p>The algorithm takes four input variables: a <em>value</em> to be converted, an
-    <tref>active subject</tref> and an <tref>active property</tref>.
-    To begin, the <tref>active subject</tref> and <tref>active property</tref> are set to <tref>null</tref>, and <em>value</em> is
+  <p>The algorithm takes five input variables: a <em>element</em> to be converted, an
+    <tref>active subject</tref>, <tref>active property</tref> and <tref>graph name</tref>.
+    To begin, the <tref>active subject</tref>, <tref>active property</tref> and <tref>graph name</tref>
+    are set to <tref>null</tref>, and <em>element</em> is
     set to the result of performing the <a href="#expansion-algorithm">Expansion Algorithm</a> on
     the <tref>JSON-LD input</tref>. This removes any existing context to allow the given context to be cleanly
     applied.</p>
 
   <ol class="algorithm">
     <li id="processing-step-associative">
-      If <em>value</em> is a <tref>JSON object</tref>, perform the following steps:
+      If <em>element</em> is a <tref>JSON object</tref>, perform the following steps:
       <ol class="algorithm">
         <li>Set <tref>active object</tref> to <tref>null</tref>.</li>
         <li>
-          If the <tref>JSON object</tref> has a <code>@value</code> key, set the <tref>active object</tref>
+          If <em>element</em> has a <code>@value</code> property, set the <tref>active object</tref>
           to a literal value as follows:
           <ol class="algorithm">
             <li>
-              as a <tref>typed literal</tref> if the <tref>JSON object</tref> contains a <code>@type</code> key
+              As a <tref>typed literal</tref> if <em>element</em> contains a <code>@type</code> property
               after performing <a href="#iri-expansion">IRI Expansion</a> on the specified <code>@type</code>.
             </li>
             <li>
-              otherwise, as a <tref>plain literal</tref>. If the <tref>JSON object</tref> contains
-              a <code>@language</code> key, use it's value to set the language of the plain literal.
-            </li>
-          </ol>
-        </li>
-        <li>
-          If the <tref>JSON object</tref> has a <code>@list</code> key the value MUST be an <tref>array</tref>.
-          Process the value as a list as described in <a href="#list-conversion">List Conversion</a> using
-          the return value as the <tref>active object</tref>
-        </li>
-        <li>If <tref>active object</tref> is not <tref>null</tref>:
-          <ol class="algorithm">
-            <li>If nether <tref>active subject</tref> nor <tref>active property</tref> are <tref>null</tref>, generate a <a>Statement</a>
-              representing the <tref>active subject</tref>, the <tref>active property</tref> and the
-              <tref>active object</tref>.</li>
-            <li>Return the <tref>active object</tref> to the calling location.</li>
-          </ol>
-        </li>
-        <li id="processing-step-subject">If the <tref>JSON object</tref> has a <code>@id</code> key:
-          <ol class="algorithm">
-            <li>
-              If the value is a <tref>string</tref>, set the <tref>active subject</tref> to the previously
-              expanded value (either a <tref>blank node</tref> or an <tref>IRI</tref>).</li>
-            <li>Otherwise,
-              Generate a create a new <tref>processor state</tref> copies of the <tref>active subject</tref>
-              and <tref>active property</tref>.
-              <ol class="algorithm">
-                <li>
-                  Process the value starting at
-                  <a href="#processing-step-associative">Step 1</a> using the returned value as
-                  <tref>active subject</tref>.
-                </li>
-                <li>Proceed using the previous <tref>processor state</tref>.</li>
-              </ol>
+              Otherwise, as a <tref>plain literal</tref>. If <em>element</em> contains
+              a <code>@language</code> property, use it's value to set the language of the plain literal.
             </li>
           </ol>
         </li>
         <li>
-          If the <tref>JSON object</tref> does not have a <code>@id</code> key, set the <tref>active
-          object</tref> to newly generated <tref>blank node</tref>.</li>
+          If <em>element</em> has a <code>@list</code> property the value MUST be an <tref>array</tref>.
+          Process its value as a list as described in <a href="#list-conversion">List Conversion</a> using
+          the return value as the <tref>active object</tref>
+        </li>
+        <li>If <tref>active object</tref> is not <tref>null</tref>:
+          <ol class="algorithm">
+            <li>If nether <tref>active subject</tref> nor <tref>active property</tref> are <tref>null</tref>,
+              generate a <a>Statement</a>
+              representing <tref>active subject</tref>, <tref>active property</tref>,
+              <tref>active object</tref>, and <tref>graph name</tref>.</li>
+            <li>Return <tref>active object</tref>.</li>
+          </ol>
+        </li>
+        <li id="processing-step-subject">If <em>element</em> has a <code>@id</code> property,
+          the value MUST be a <tref>string</tref>, set the <tref>active subject</tref> to the previously
+          expanded value (either a <tref>blank node</tref> or an <tref>IRI</tref>).</li>
         <li>
-          For each key in the <tref>JSON object</tref> that has not already been processed, perform
-          the following steps:
+          Otherwise, if <em>element</em> does not have a <code>@id</code> property, set the <tref>active
+          subject</tref> to newly generated <tref>blank node</tref>.</li>
+        <li>
+          Process each <em>property</em> and <em>value</em> in <em>element</em> as follows:
           <ol class="algorithm">
             <li>
-              If the key is <code>@type</code>, set the <tref>active property</tref>
+              If <em>property</em> is <code>@type</code>, set the <tref>active property</tref>
               to <code>rdf:type</code>.
             </li>
-            <li>Otherwise, if the key is a <tref>keyword</tref>, skip this step.</li>
-            <li>Otherwise, set <tref>active property</tref> to the value of the key.</li>
-            <li>
-              Create a new <tref>processor state</tref> copies of
-              <tref>active subject</tref> and <tref>active property</tref> and process the value
-              starting at <a href="#processing-step-associative">Step 1</a> and proceed using the
-              previous <tref>processor state</tref>.
+            <li>Otherwise, if <em>property</em> is <code>@graph</code>,
+              process <em>value</em> algorithm recursively, using <tref>active subject</tref> as <tref>graph name</tref>
+              and null values for <tref>active subject</tref> and <tref>active property</tref> and then
+              proceed to next property.</li>
+            <li>Otherwise, if <em>property</em> is a <tref>keyword</tref>, skip this step.</li>
+            <li>Otherwise, set <tref>active property</tref> to the IRI value of <em>property</em>.</li>
+            <li>Process <em>value</em> recursively using this algorithm, passing copies of
+              <tref>active subject</tref>, <tref>active property</tref> and <tref>graph name</tref>.
             </li>
           </ol>
         </li>
         <li>
-          Return the <tref>active subject</tref> to the calling location.
+          Set <tref>active object</tref> to <tref>active subject</tref>.
         </li>
       </ol>
     </li>
 
-    <li>If a regular <tref>array</tref> is detected, process each value in the <tref>array</tref>
-      by doing the following returning the result of processing the last value in the <tref>array</tref>:
-      <div class="issue">Update based on decision of what value, if any, of array to use.</div>
-      <ol class="algorithm">
-        <li>
-          Create a new <tref>processor state</tref> using copies of <tref>active subject</tref> and
-          <tref>active property</tref> and process the value
-          starting at <a href="#processing-step-associative">Step 1</a> then proceed using the previous
-          <tref>processor state</tref>.
-        </li>
-      </ol>
-    </li>
+    <li>Otherwise, if <em>element</em> is an <tref>array</tref>, process each value in the <tref>array</tref>
+      as follows, process <em>element</em> recursively using this algorithm, using copies of
+      <tref>active subject</tref>, <tref>active property</tref>, and <tref>graph name</tref>.</li>
 
-    <li>
-      If a <tref>string</tref> is detected, set the <tref>active object</tref>
+    <li>Otherwise, if <em>element</em> is a <tref>string</tref>, set the <tref>active object</tref>
       to a <tref>plain literal</tref> value created from the string.</li>
-    <li>
-      If a <tref>number</tref> is detected, set the <tref>active object</tref> to a
+
+    <li>Otherwise, if <em>element</em> is a <tref>number</tref>, set the <tref>active object</tref> to a
       <tref>typed literal</tref> using a string representation of the value with datatype set
       to either <code>xsd:integer</code> or <code>xsd:double</code>, depending on if the value
       contains a fractional and/or an exponential component.</li>
-    <li>
-      Otherwise, if <strong>true</strong> or <strong>false</strong> is detected,
+
+    <li>Otherwise, if <em>element</em> is <strong>true</strong> or <strong>false</strong>,
       set the <tref>active object</tref> to a <tref>typed literal</tref> created from the
-      string representation of the value with datatype set to <code>xsd:boolean</code>.
+      string representation of the value with datatype set to <code>xsd:boolean</code>.</li>
+
+    <li>If any of these steps created an <tref>active object</tref> and neither <tref>active subject</tref>
+      nor <tref>active property</tref> are <tref>null</tref>, generate a <a>Statement</a> using
+      <tref>active subject</tref>,<tref>active property</tref>, <tref>active object</tref> and
+      <tref>graph name</tref>.
     </li>
-    <li>
-      If any of these steps created an <tref>active object</tref> and neither <tref>active subject</tref>
-      nor <tref>active property</tref> are <tref>null</tref>, generate a <a>Statement</a> using <tref>active subject</tref>,
-      <tref>active property</tref> and <tref>active object</tref>
-    </li>
-    <li>Return <tref>active object</tref> to the calling location.</li>
+    <li>Return <tref>active object</tref>.</li>
   </ol>
 </section>
 <section id="list-conversion">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/rdf-0027.jsonld	Thu Apr 12 14:48:13 2012 -0400
@@ -0,0 +1,30 @@
+{
+  "@context": {
+    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+    "ex": "http://example.org/",
+    "xsd": "http://www.w3.org/2001/XMLSchema#",
+    "ex:locatedIn": {"@type": "@id"},
+    "ex:hasPopulaton": {"@type": "xsd:integer"},
+    "ex:hasReference": {"@type": "@id"}
+  },
+  "@graph": [
+    {
+      "@id": "http://example.org/ParisFact1",
+      "@type": "rdf:Graph",
+      "@graph": {
+        "@id": "http://example.org/location/Paris#this",
+        "ex:locatedIn": "http://example.org/location/France#this"
+      },
+      "ex:hasReference": ["http://www.britannica.com/", "http://www.wikipedia.org/", "http://www.brockhaus.de/"]
+    },
+    {
+      "@id": "http://example.org/ParisFact2",
+      "@type": "rdf:Graph",
+      "@graph": {
+        "@id": "http://example.org/location/Paris#this",
+        "ex:hasPopulation": 7000000
+      },
+      "ex:hasReference": "http://www.wikipedia.org/"
+    }
+  ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/rdf-0027.sparql	Thu Apr 12 14:48:13 2012 -0400
@@ -0,0 +1,19 @@
+PREFIX ex: <http://example.org/> 
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+
+ASK
+WHERE {
+  ex:ParisFact1 a rdf:Graph;
+    ex:hasReference <http://www.britannica.com/>,
+      <http://www.wikipedia.org/>,
+      <http://www.brockhaus.de/> .
+  ex:ParisFact2 a rdf:Graph;
+    ex:hasReference <http://www.wikipedia.org/> .
+  GRAPH ex:ParisFact1 {
+    <http://example.org/location/Paris#this> ex:locatedIn <http://example.org/location/France#this> .
+  }
+  GRAPH ex:ParisFact2 {
+    <http://example.org/location/Paris#this> ex:locatedIn <http://example.org/location/France#this> .
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/rdf-0028.jsonld	Thu Apr 12 14:48:13 2012 -0400
@@ -0,0 +1,19 @@
+{
+  "@context": {
+    "sec": "http://purl.org/security#",
+    "xsd": "http://www.w3.org/2001/XMLSchema#",
+    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+    "dc": "http://purl.org/dc/terms/",
+    "sec:signer": {"@type": "@id"},
+    "dc:created": {"@type": "xsd:dateTime"}
+  },
+  "@id": "http://example.org/sig1",
+  "@type": ["rdf:Graph", "sec:SignedGraph"],
+  "dc:created": "2011-09-23T20:21:34Z",
+  "sec:signer": "http://payswarm.example.com/i/john/keys/5",
+  "sec:signatureValue": "OGQzNGVkMzVm4NTIyZTkZDYMmMzQzNmExMgoYzI43Q3ODIyOWM32NjI=",
+  "@graph": {
+    "@id": "http://example.org/fact1",
+    "dc:title": "Hello World!"
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/rdf-0028.sparql	Thu Apr 12 14:48:13 2012 -0400
@@ -0,0 +1,14 @@
+PREFIX dc: <http://purl.org/dc/terms/>
+PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX sec: <http://purl.org/security#>
+PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+
+ASK WHERE {
+  <http://example.org/sig1> a rdf:Graph, sec:SignedGraph;
+    dc:created "2011-09-23T20:21:34Z"^^xsd:dateTime;
+    sec:signatureValue "OGQzNGVkMzVm4NTIyZTkZDYMmMzQzNmExMgoYzI43Q3ODIyOWM32NjI=";
+    sec:signer <http://payswarm.example.com/i/john/keys/5> .
+  GRAPH <http://example.org/sig1> {
+    <http://example.org/fact1> dc:title "Hello World!" .
+  }
+}
--- a/test-suite/tests/rdf-manifest.jsonld	Thu Apr 12 14:48:00 2012 -0400
+++ b/test-suite/tests/rdf-manifest.jsonld	Thu Apr 12 14:48:13 2012 -0400
@@ -161,6 +161,18 @@
       "name": "Test creation of multiple types",
       "purpose": "Tests that @type with an array of types creates multiple types.",
       "sparql": "rdf-0026.sparql"
+    }, {
+      "@type": ["test:TestCase", "jld:RDFTest"],
+      "input": "rdf-0027.jsonld",
+      "name": "Simple named graph (Wikidata)",
+      "purpose": "Using @graph with other keys places triples in a named graph.",
+      "sparql": "rdf-0027.sparql"
+    }, {
+      "@type": ["test:TestCase", "jld:RDFTest"],
+      "input": "rdf-0028.jsonld",
+      "name": "Simple named graph",
+      "purpose": "Signing a graph.",
+      "sparql": "rdf-0028.sparql"
     }
   ]
 }