--- a/spec/latest/json-ld-api/index.html Mon Feb 18 14:31:11 2013 -0800
+++ b/spec/latest/json-ld-api/index.html Mon Feb 18 14:31:41 2013 -0800
@@ -185,6 +185,28 @@
knowledge of the JavaScript programming language [[ECMA-262]] and
WebIDL [[!WEBIDL]]. To understand how JSON-LD maps to RDF, it is helpful to be
familiar with the basic RDF concepts [[!RDF-CONCEPTS]].</p>
+
+ <p>Throughout this document, <tref title="compact iri">compact IRIs</tref>
+ are used without prefix definitions.
+ The examples throughout this document assume that the following
+ vocabulary <tref title="prefix">prefixes</tref> have been defined:</p>
+ <table>
+ <tbody>
+ <tr>
+ <td rowspan="1" colspan="1">rdf:</td>
+ <td rowspan="1" colspan="1">
+ http://www.w3.org/1999/02/22-rdf-syntax-ns#</td>
+ </tr>
+ <tr>
+ <td rowspan="1" colspan="1">rdfs:</td>
+ <td rowspan="1" colspan="1"> http://www.w3.org/2000/01/rdf-schema#</td>
+ </tr>
+ <tr>
+ <td rowspan="1" colspan="1">xsd:</td>
+ <td rowspan="1" colspan="1">http://www.w3.org/2001/XMLSchema#</td>
+ </tr>
+ </tbody>
+ </table>
</section>
<section class="informative">
@@ -315,7 +337,7 @@
that consume JSON or JSON-LD by expressing the data in application-specific
terms, and it makes the data easier to read by humans.</p>
- <tref>Compaction</tref> uses a developer-supplied <tref>context</tref> to
+ <p><tref>Compaction</tref> uses a developer-supplied <tref>context</tref> to
shorten <tref title="IRI">IRIs</tref> to <tref title="term">terms</tref> or
<tref title="compact IRI">compact IRIs</tref> and
<tref title="JSON-LD value">JSON-LD values</tref> expressed in
@@ -745,15 +767,17 @@
<dt><tdef>scalar</tdef></dt>
<dd>A scalar is either a JSON <tref>string</tref>, <tref>number</tref>, <tref>true</tref>,
or <tref>false</tref>.</dd>
- <dt><tdef>quad</tdef></dt>
- <dd>An <em>RDF triple</em> as specified by [[RDF-CONCEPTS]] augmented with
- a fourth component, a <tref>graph name</tref>.</dd>
- <dt><tdef>RDF subject</tdef></dt>
- <dd>A <em>subject</em> as specified by [[RDF-CONCEPTS]].</dd>
- <dt><tdef>RDF predicate</tdef></dt>
- <dd>A <em>predicate</em> as specified by [[RDF-CONCEPTS]].</dd>
- <dt><tdef>RDF object</tdef></dt>
- <dd>An <em>object</em> as specified by [[RDF-CONCEPTS]].</dd>
+ <dt><tdef>RDF subject</tdef></dt>
+ <dd>A <tref href="http://www.w3.org/TR/rdf11-concepts/#dfn-subject">subject</tref> as specified by [[RDF-CONCEPTS]].</dd>
+ <dt><tdef>RDF predicate</tdef></dt>
+ <dd>A <tref href="http://www.w3.org/TR/rdf11-concepts/#dfn-predicate">predicate</tref> as specified by [[RDF-CONCEPTS]].</dd>
+ <dt><tdef>RDF object</tdef></dt>
+ <dd>An <tref href="http://www.w3.org/TR/rdf11-concepts/#dfn-object">object</tref> as specified by [[RDF-CONCEPTS]].</dd>
+ <dt><tdef>RDF triple</tdef></dt>
+ <dd>An <tref href="http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple">triple</tref> as specified by [[RDF-CONCEPTS]].</dd>
+ <dt><tdef>RDF dataset</tdef></dt>
+ <dd>An <tref href="http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset">dataset</tref> as specified by [[RDF-CONCEPTS]] representing a collection of
+ <tref href="http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-graph">RDF graphs</tref>.</dd>
</dl>
</section>
@@ -830,7 +854,7 @@
optionally a <tdef>type mapping</tdef> from terms to datatypes or
<tdef>language mapping</tdef> from terms to language codes, and a
<tdef>container mapping</tdef>. If an <tref>IRI mapping</tref> maps a term
-to multiple <tref="IRI">IRIs</tref> it is said to be a
+to multiple <tref title="IRI">IRIs</tref> it is said to be a
<tdef>property generator</tdef>. The <tref>active context</tref> also
keeps track of <tref>keyword</tref> aliases.
</p>
@@ -904,7 +928,7 @@
<p>
This algorithm specifies how a new <tref>active context</tref> is updated
with a <tref>local context</tref>. The algorithm takes two input variables:
-an <tref>active context</tref> and a <tref>local context</tref>.
+an <tref>active context</tref> and a <tref>local context</tref>.</p>
<ol class="algorithm">
<li>
@@ -1138,8 +1162,7 @@
If <em>id</em> is an <tref>array</tref>, then the
<tref>term definition</tref> is for a <tref>property generator</tref>:
<ol class="algorithm">
- <li>
- Create an empty <tref>array</tref> <em>property generator</em>.
+ <li>Create an empty <tref>array</tref> <em>property generator</em>.</li>
<li>
For each item <em>iri</em> in <em>id</em>:
<ol class="algorithm">
@@ -1404,7 +1427,7 @@
Initialize <em>expanded active property</em> to the result of the
<a href="#iri-expansion">IRI Expansion</a> algorithm, passing
<tref>active context</tref>, <tref>active property</tref> for
- <em>value</em>, and <tref>true</tref> for <em>vocabRelative</em>.
+ <em>value</em>, and <tref>true</tref> for <em>vocabRelative</em>.</li>
<li>
Initialize an empty <tref>JSON object</tref>, <em>result</em>.
</li>
@@ -1537,7 +1560,7 @@
using this algorithm recursively, passing
<tref>active context</tref>, <tref>active property</tref>,
<em>index value</em> as <em>element</em>, and
- <tref>false</tref> for <em>insideList</em>.
+ <tref>false</tref> for <em>insideList</em>.</li>
<li>
For each <em>item</em> in <em>index value</em>:
<ol class="algorithm">
@@ -1691,7 +1714,7 @@
<li>
If <em>result</em> contains no keys or contains the key
<code>@value</code>, setting <em>result</em> to
- <tref>null</tref>.
+ <tref>null</tref>.</li>
<li>
Otherwise, if <em>result</em>'s keys are only keywords and none
of the keys are <code>@graph</code> or <code>@type</code> then
@@ -1903,7 +1926,7 @@
<em>result</em> MUST be an <tref>absolute IRI</tref>. Otherwise,
an invalid context value has been detected, which is an error. Return
<em>result</em>.</li>
- </li>
+ </ol>
</section>
</section> <!-- end of IRI Expansion -->
@@ -2475,7 +2498,7 @@
Initialize <em>compacted item</em> to the result of using
this algorithm recursively, passing
<tref>active context</tref>, <em>item active property</em>
- for </tref>active property</tref>,
+ for <tref>active property</tref>,
<em>expanded item</em> for <em>element</em> if it does
not contain the key <code>@list</code>, otherwise pass
the key's associated value for <em>element</em>.
@@ -2740,6 +2763,7 @@
<tref>type mapping</tref> or <tref>language mapping</tref> for
a <tref>term</tref>, based on what is compatible with <em>value</em>.
</li>
+ <li>
If <em>value</em> is a <tref>list object</tref>, then set
<em>typeOrLanguage</em> and <em>typeOrLanguageValue</em>
to the most specific values that work for all items in
@@ -3037,13 +3061,14 @@
<ol class="algorithm">
<li>
Initialize <em>result</em> to an empty <tref>JSON object</tref>.
+ </li>
<li>
Initialize <em>defaultLanguage</em> to <code>@none</code>. If the
<tref>active context</tref> has a <tref>default language</tref>, then
set <em>defaultLanguage</em> to it.
</li>
<li>
- For each key <tref>term</tref> and value <term>term definition</tref> in
+ For each key <tref>term</tref> and value <tref>term definition</tref> in
the <tref>active context</tref>, ordered by shortest <tref>term</tref>
first (breaking ties by choosing the lexicographically least
<tref>term</tref>):
@@ -3818,7 +3843,7 @@
The resulting <em>nodeMap</em> will have a member for every graph in the document whose
value is another object with a member for every <tref>node</tref> represented in the document.
The default graph is stored under the <code>@default</code> member, all other graphs are
- stored under their graph name</tref>.</p>
+ stored under their <tref>graph name</tref>.</p>
<p>The algorithm takes as input an expanded JSON-LD document <em>element</em> and a reference to
a <tref>JSON object</tref> <em>nodeMap</em>. Furthermore it has the optional parameters
@@ -3912,272 +3937,278 @@
</ol>
</section>
-<!-- FIXME -->
+
<section>
-<h2>RDF Conversion Algorithms</h2>
-
-<p>
-This section describes algorithms to transform JSON-LD documents to an array
-of RDF <tref title="quad">quads</tref> and vice-versa. Note that many uses of
-JSON-LD may not require generation of RDF.
-</p>
+<h2>Convert to RDF Algorithm</h2>
<p>
-The processing algorithms described in this section are provided in order to
-demonstrate how one might implement a JSON-LD to RDF processor. Conformant
-implementations are only required to produce the same type and number of
-<tref title="quad">quads</tref> but are not required to implement the
-algorithm exactly as described.
-</p>
-
-<section>
-<h3>Convert to RDF Algorithm</h3>
-
-<p>
+This section describes algorithms to transform a JSON-LD document to an <tref>RDF dataset</tref>.
The algorithm below is designed for in-memory implementations with random
access to <tref>JSON object</tref> elements.
</p>
<p>
A conforming JSON-LD processor implementing RDF conversion MUST implement a
-processing algorithm that results in the same set of RDF
-<tref title="quad">quads</tref> that the following algorithm generates.
+processing algorithm that results in the same <tref>RDF dataset</tref> that the following algorithm generates. Conformant
+implementations are only required to produce the same <tref>RDF dataset</tref> but are not required to implement the algorithm exactly as described.
</p>
+<section class="informative">
+ <h3>Purpose</h3>
+ <p>A JSON-LD document needs to be converted to an <tref>RDF dataset</tref>.</p>
+</section>
+
+<section class="informative">
+ <h4>General Solution</h4>
+
+ <p>The JSON-LD document is expanded converted to a <em>node map</em> using the
+ <a href="#node-map-generation">Node Map Generation algorithm</a>.
+ This allows each graph represented within the document to be
+ extracted and flattened, making it easier to process each
+ <tref>node object</tref>. Each graph from the <em>node map</em>
+ is processed to extract <tref title="rdf triple">RDF triples</tref>, to which any (non-default) graph name
+ is applied to create an <tref>RDF dataset</tref>.
+ </p>
+</section>
+
+<section>
+<h4>Algorithm</h4>
<p>
-The algorithm takes five input variables: an <em>element</em> to be converted,
-an <tref>active subject</tref>, an <tref>active property</tref>, a
-<tref>graph name</tref>, and an <tref>array</tref> <em>quads</em> of
-<tref title="quad">Quads</tref>. To begin, the <tref>active subject</tref>,
-<tref>active property</tref>, and <tref>graph name</tref>
-are set to <tref>null</tref>, <em>quads</em> is set to an empty
-<tref>array</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> which is expected to be a a well-formed JSON-LD
-document as defined in [[!JSON-LD]].
+The algorithm takes a JSON-LD document <em>element</em> and creates an <tref>RDF dataset</tref>.
</p>
-<p class="issue">This algorithm hasn't been updated to use [[!RDF-CONCEPTS]]
-yet.</p>
-<p class="issue">This algorithm needs some clarification on its details.</p>
-
<ol class="algorithm">
- <li>
- If <em>element</em> is an <tref>array</tref>, then for each <em>item</em>
- in <em>element</em> invoke this algorithm recursively, passing
- <em>item</em> for <em>element</em>, <tref>active subject</tref>,
- <tref>active property</tref>, <tref>graph name</tref>, and <em>quads</em>.
+ <li>Expand <em>element</em> according the
+ <a href="#expansion-algorithm">Expansion algorithm</a>.</li>
+ <li>Generate a <em>nodeMap</em> according the
+ <a href="#node-map-generation">Node Map Generation Subalgorithm</a>.</li>
+ <li>Initialize an empty <tref>RDF dataset</tref> <em>dataset</em>.</li>
+ <li>For each <em>graph name</em> and <em>graph</em> in <em>nodeMap</em>:
+ <ol class="algorithm">
+ <li>Retrieve <em>triples</em> using the <a href="#nodemap-rdf">Node Map to RDF Subalgorithm</a>.</li>
+ <li>If <em>graph name</em> is not <code>@default</code>, add
+ <em>triples</em> to the <tref>default graph</tref> in <em>dataset</em>.</li>
+ <li>Otherwise, create a <tref>named graph</tref> in <em>dataset</em>
+ composed of <em>graph name</em> and <em>triples</em>.</li>
+ </ol>
</li>
- <li>
- Otherwise, if <em>element</em> is a <tref>string</tref>, then
- generate a <tref>quad</tref> using <tref>active subject</tref>,
- <tref>active property</tref>, an <tref>IRI</tref> with the value
- of <em>element</em> for <tref>RDF object</tref>, and
- <tref>graph name</tref>. Append the <tref>quad</tref> to
- <em>quads</em>.
- </li>
- <li>
- Otherwise, if <em>element</em> is a <tref>list object</tref>:
+ <li>Return <em>dataset</em>.</li>
+</ol>
+</section>
+</section> <!-- Convert to RDF Algorithm -->
+
+<section id="nodemap-rdf">
+<h3>Node Map to RDF Subalgorithm</h3>
+<p>This algorithm takes the a <em>Node Map</em> for a particular graph
+ as generated by the
+ <a href="#node-map-generation">Node Map Generation Subalgorithm</a>
+ and returns a set of <em>RDF triples</em>.</p>
+
+<section class="informative">
+ <h4>Purpose</h4>
+ <p>Given a set of <tref title="node">nodes</tref> associated with a
+ <tref>JSON-LD graph</tref> as obtained from the <a href="">Node Map Generation</a>
+ algorithm, transform each <tref>node</tref> into one or more <tref
+ title="RDF triple">RDF triples</tref>.</p>
+</section>
+
+<section class="informative">
+ <h4>General Solution</h4>
+
+ <p>Identify <tref title="RDF subject">RDF subjects</tref> and
+ <tref title="RDF predicate">RDF predicates</tref> from the
+ <tref>node</tref> identifier and properties. Transform each property value
+ into an <tref>IRI</tref> or
+ <tref
+ href="http://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literal</tref>
+ to generate an <tref>RDF triple</tref>.
+ <tref title="list">Lists</tref> are transformed into an
+ <tref
+ href="http://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF Collection</tref>
+ using the <a href="#list-conversion">List to RDF Conversion Subalgorithm.</a></p>
+</section>
+
+<section>
+<h4>Algorithm</h4>
+<p>The <em>nodeMap</em> is represented as an <tref>JSON object</tref>
+ having keys which are node identifiers (<tref title="iri">IRIs</tref> or
+ <tref title="blank node identifier">blank node identifiers</tref>)
+ and values are <tref title="node object">Node objects</tref>.</p>
+<ol class="algorithm">
+ <li>Initialize <em>result</em> as an empty <tref>array</tref>.</li>
+ <li>For each <em>subject</em> and <em>node</em> in <em>nodeMap</em>:
<ol class="algorithm">
- <li>
- Initialize <em>list</em> to the result of the
- <a href="#list-conversion">List Conversion</a> algorithm, passing
- the value associated with the <code>@list</code> key.
- </li>
- <li>
- Invoke this algorithm recursively, passing <em>list</em> for
- <em>element</em>, <tref>active subject</tref>,
- <tref>active property</tref>, <tref>graph name</tref>, and
- <em>quads</em>.
+ <li>For each <em>property</em> and <em>values</em> in <em>node</em>:
+ <ol class="algorithm">
+ <li>If <em>property</em> is <code>@type</code>, then for each
+ <em>type</em> in <em>values</em>, append a <tref>triple</tref>
+ composed of <em>subject</em>, <code>rdf:type</code>,
+ and <em>type</em> to <em>result</em>.</li>
+ <li>Otherwise, if <em>property</em> is a <tref>keyword</tref>
+ continue to the next <em>property</em>-<em>values</em> pair.</li>
+ <li>Otherwise, <em>property</em> is an <tref>IRI</tref> or
+ <tref>blank node identifier</tref>.</li>
+ <li>For each <em>item</em> in <em>values</em>:
+ <ol class="algorithm">
+ <li>If <em>item</em> is a <tref>list object</tref>, initialize
+ <em>list result</em> as an empty <tref>array</tref>, and
+ <em>object</em> to the result of the <a
+ href="#list-conversion">List Conversion algorithm</a>, passing
+ the value associated with the <code>@list</code> key from
+ <em>item</em> and <em>list result</em>. Append a
+ <tref>triple</tref> composed of <em>subject</em>,
+ <em>property</em>, and <em>object</em> to <em>result</em> and
+ add all <tref title="triple">triples</tref> from <em>list
+ result</em> to <em>result</em>.</li>
+ <li>Otherwise, <em>item</em> is a <tref>value object</tref>
+ or a <tref>node object</tref>. Generate <em>object</em> as
+ the result of the <a href="#rdf-object-conversion">Object to
+ RDF Conversion Subalgorithm</a> passing <em>item</em>. Append a
+ <tref>triple</tref> composed of <em>subject</em>,
+ <em>property</em>, and <em>object</em> to <em>result</em>.</li>
+ </ol>
+ </li>
+ </ol>
</li>
</ol>
</li>
- <li>
- Otherwise, if <em>element</em> is a <tref>JSON object</tref> that
- contains the key <code>@value</code>:
+ <li>Return <em>result</em>.</li>
+</ol>
+</section>
+</section> <!-- Node Map to RDF Subalgorithm -->
+
+<section id="rdf-object-conversion">
+<h3>Object to RDF Conversion Subalgorithm</h3>
+<p>This algorithm takes a <tref>node</tref> or <tref>value object</tref>
+ and transforms it into an <tref
+ href="http://www.w3.org/TR/rdf11-concepts/#dfn-resource">RDF resource</tref>
+ to be used as the <tref>object</tref> or an <tref>RDF triple</tref>.</p>
+
+<section class="informative">
+ <h4>Purpose</h4>
+ <p>Create an <tref>RDF resource</tref> from a <tref>node</tref> or <tref>value object</tref>.</p>
+</section>
+
+<section class="informative">
+ <h4>General Solution</h4>
+
+ <p>Transform <tref title="value object">value objects</tref> to their
+ <tref>RDF literal</tref> form and
+ <tref title="node object">node objects</tref> to an
+ <tref>RDF resource</tref>.</p>
+</section>
+
+<section>
+<h4>Algorithm</h4>
+<p>The algoritm takes as it's sole argument <em>item</em> which MUST BE either a <tref>value object</tref> or <tref>node object</tref>.</p>
+<ol class="algorithm">
+ <li>If <em>item</em> is a <tref>value object</tref>:
<ol class="algorithm">
- <li>
- Initialize <em>value</em> to the value associated with the
- <code>@value</code> key in <em>element</em>. Initialize
- <em>datatype</em> to the value associated with the <code>@type</code>
- key in <em>element</em>, or <tref>null</tref> if <em>element</em>
- does not contain that key.
- </li>
- <li>
- Otherwise, if <em>value</em> equals <tref>true</tref> or
- <tref>false</tref>, then set <em>value</em> its
+ <li>Initialize <em>value</em> to the value associated with the
+ <code>@value</code> key in <em>item</em>. Initialize <em>datatype</em>
+ to the value associated with the <code>@type</code> key in
+ <em>item</em>, or <code>null</code> if <em>item</em> does not contain
+ that key.</li>
+ <li>If value is true or false, then set value its canonical lexical form as defined in the section Data Round Tripping. If datatype is null, set it to xsd:boolean.</li>
+ <li>If <em>value</em> is <tref>true</tref> or
+ <tref>false</tref>, then set <em>value</em> to its
<tref>canonical lexical form</tref> as defined
in the section <a href="#data-round-tripping">Data Round Tripping</a>.
If <em>datatype</em> is <tref>null</tref>, set it to
- <code>xsd:boolean</code>.
- </li>
- <li>
- Otherwise, if <em>value</em> is a <tref>number</tref>, then set
+ <code>xsd:boolean</code>.</li>
+ <li>Otherwise, if <em>value</em> is a <tref>number</tref>, then set
<em>value</em> to its <tref>canonical lexical form</tref> as defined
in the section <a href="#data-round-tripping">Data Round Tripping</a>.
If <em>datatype</em> is <tref>null</tref>, set it 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 <em>datatype</em> is <tref>null</tref>, set it to
- <code>xsd:string</code>.
- </li>
- <li>
- Initialize <tref>active object</tref> using <em>value</em> and
- <em>datatype</em>. If <em>element</em> has the key
- <code>@language</code> and <em>datatype</em> equals
- <code>xsd:string</code>, then add the value associated with the
- <code>@language</code> key as the language of the
- <tref>active object</tref>.
- </li>
- <li>
- Generate a <tref>quad</tref> using <tref>active subject</tref>,
- <tref>active property</tref>, <tref>active object</tref>, and
- <tref>graph name</tref>. Append the <tref>quad</tref> to
- <em>quads</em>.
- </li>
+ component.</li>
+ <li>Otherwise, if <em>datatype</em> is <tref>null</tref>, set it to
+ <code>xsd:string</code> or <code>rdf:langString</code>, depending on if
+ item has a <code>@language</code> key.</li>
+ <li>Initialize <em>literal</em> as an <tref>RDF literal</tref> using
+ <em>value</em> and <em>datatype</em>. If <em>item</em> has the key
+ <code>@language</code> and <em>datatype</em> is
+ <code>rdf:langString</code>, then add the value associated with the
+ <code>@language</code> key as the language of <em>literal</em>.</li>
+ <li>Return <em>literal</em>.</li>
</ol>
</li>
- <li>
- Otherwise, <em>element</em> must represent the next
- <tref>RDF subject</tref> to be processed:
- <ol class="algorithm">
- <li>
- If <em>element</em> contains the key <code>@id</code>, then
- initialize <em>id</em> to its associated value, otherwise initialize
- it to <tref>null</tref>. If <em>element</em> is a
- <tref>blank node</tref>, then set <em>id</em> to the result of
- using the
- <a href="#generate-blank-node-identifier">Generate Blank Node Identifier</a>
- algorithm, passing <em>id</em> for <em>identifier</em>.
- </li>
- <li>
- Initialize <tref>active object</tref> to an <tref>IRI</tref> or
- <tref>blank node</tref>, as appropriate, with the value of
- <em>element</em>.
- </li>
- <li>
- If <tref>active subject</tref> is not <tref>null</tref>, then
- generate a <tref>quad</tref> using <tref>active subject</tref>,
- <tref>active property</tref>, <tref>active object</tref>, and
- <tref>graph name</tref>. Append the <tref>quad</tref> to
- <em>quads</em>.
- </li>
- <li>
- Set <tref>active subject</tref> to <tref>active object</tref>.
- </li>
- <li>
- For each <em>key</em>-<em>value</em> pair in <em>element</em>,
- sorted lexicographically by <em>key</em>:
- <ol class="algorithm">
- <li>
- Set <tref>active property</tref> to <em>value</em>.
- </li>
- <li>
- If <tref>active property</tref> equals <code>@graph</code>, then
- use this algorithm recursively, passing <em>value</em> for
- <em>element</em>, <tref>null</tref> for
- <tref>active subject</tref> and <tref>active property</tref>,
- <tref>active subject</tref> for <tref>graph name</tref>,
- and <em>quads</em>. Then continue to the next <em>key</em>.
- </li>
- <li>
- If <em>key</em> equals <code>@type</code>, then set
- <tref>active property</tref> to <code>rdf:type</code>.
- </li>
- <li>
- If <tref>active property</tref> is a <tref>keyword</tref>,
- then continue to the next <em>key</em>.
- </li>
- <li>
- Use this algorithm recursively, passing <em>value</em> for
- <em>element</em>, <tref>active subject</tref>,
- <tref>active property</tref>, <tref>graph name</tref>,
- and <em>quads</em>.
- </li>
- </ol>
- </li>
- </ol>
- </li>
+ <li>Otherwise, <em>item</em> MUST BE a <tref>node object</tref> containing only <code>@id</code> having an <tref>IRI</tref> or <tref>blank node identifier</tref> value. Return that value.</li>
</ol>
-
+</section>
+</section> <!-- Object to RDF Conversion Subalgorithm -->
+
+<section id="list-conversion">
+<h3>List to RDF Conversion Subalgorithm</h3>
+
+<p>
+ List Conversion is the process of taking a <tref>list</tref> <tref>node</tref>
+ and transforming it into an
+ <tref href="http://www.w3.org/TR/rdf-schema/#ch_collectionvocab">
+ RDF Collection
+ </tref> as defined in [[!RDF-MT]].</p>
+<div class="note">This algorithm does not support lists containing lists.</div>
+
+
+<section class="informative">
+ <h4>Purpose</h4>
+ <p>Transform a sequential set of <tref title="node">nodes</tref> in a <tref>list</tref> into the equivalent <tref>RDF Collection</tref>.</p>
+</section>
+
+<section class="informative">
+ <h4>General Solution</h4>
+
+ <p>Allocate a new <tref>blank node</tref> for each element of the
+ <tref>list</tref> and generate <code>rdf:first</code> and
+ <code>rdf:rest</code> <tref title="RDF triple">triples</tref> for each,
+ returning the first <tref>blank node</tref> or <code>rdf:nil</code> if the
+ list is empty.</p>
</section>
<section>
-<h3>List Conversion</h3>
-
-<p>
-List Conversion is the process of taking an <tref>array</tref> of values and
-converting it to a JSON-LD linked list of
-<tref title="JSON object">JSON objects</tref>. Each element of the list is
-linked by using <code>rdf:first</code> and <code>rdf:rest</code>, terminating
-the list with <code>rdf:nil</code>.
-</p>
-
-<p>
-The algorithm takes a single input: an <tref>array</tref> <em>list</em>.
-</p>
-
-<div class="note">This algorithm does not support lists containing lists.</div>
+<h4>Algorithm</h4>
+<p>The algorithm takes two inputs: an <tref>array</tref> of
+ <tref title="node">nodes</tref> <em>list</em> and an empty <tref>array</tref>
+ <em>list triples</em> used for returning the generated <tref title="RDF
+ triple">triples</tref>.</p>
<ol class="algorithm">
- <li>
- Initialize <em>length</em> to the length of <em>list</em>.
- </li>
- <li>
- Initialize <em>tail</em> to a <tref>JSON object</tref> containing
- one key-value pair, (<code>@id</code>-<code>rdf:nil</code>).
- </li>
- <li>
- Starting <em>itr</em> at <em>length</em> minus <code>1</code>, loop
- until <em>itr</em> is <code>0</code> (inclusive):
+ <li>Create a new <tref>array</tref> <em>array</em> composed of a
+ <a href="#generate-blank-node-identifier">new blank node identifier</a>
+ for each entry in <em>list</em>.</li>
+ <li>For each pair of <em>subject</em> from <em>array</em> and <em>item</em> from <em>list</em>:
<ol class="algorithm">
- <li>
- Initialize <em>element</em> to an empty <tref>JSON object</tref>.
- </li>
- <li>
- Add a key-value pair to <em>element</em> where the key is
- <code>rdf:first</code> and the value is an <tref>array</tref>
- containing the value associated with the index <em>itr</em>
- in <em>list</em>.
- </li>
- <li>
- Add a key-value pair to <em>element</em> where the key is
- <code>rdf:rest</code> and the value is an <tref>array</tref>
- containing <em>tail</em>.
- </li>
- <li>
- Set <em>tail</em> to <em>element</em>.
- </li>
- <li>
- Decrement <em>itr</em> by <code>1</code>.
- </li>
+ <li>Generate <em>object</em> as
+ the result of the <a href="#rdf-object-conversion">Object to
+ RDF Conversion Subalgorithm</a> passing <em>item</em>. Append a
+ <tref>triple</tref> composed of <em>subject</em>,
+ <code>rdf:first</code>, and <em>object</em> to <em>list triples</em>.</li>
+ <li>Set <em>rest</em> as the next entry in <em>array</em>, or if that
+ does not exist, <code>rdf:nil</code>. Append a
+ <tref>triple</tref> composed of <em>subject</em>,
+ <code>rdf:rest</code>, and <em>rest</em> to <em>list triples</em>.</li>
</ol>
</li>
- <li>
- Return <em>tail</em>.
- </li>
+ <li>Return the first <tref>blank node</tref> from <em>array</em> or
+ <code>rdf:nil</code> if <em>array</em> is empty.</li>
</ol>
-
- </section>
+</section>
+</section> <!-- List to RDF Subalgorithm -->
<!-- FIXME -->
<section>
<h2>Convert from RDF Algorithm</h2>
- <p>In some cases, data exists natively in the form of triples or or <tref title="quad">quads</tref>;
- for example, if the data was originally represented in an RDF graph or triple/quad store. This
- algorithm is designed to simply translate an array of <tref title="quad">quads</tref> into a
+ <p>In some cases, data exists natively in the form of triples or or <tref title="triple">triples</tref>;
+ for example, if the data was originally represented in an <tref>RDF dataset</tref>. This
+ algorithm is designed to simply translate an array of <tref title="triple">triples</tref> into a
JSON-LD document.</p>
<p>When expanding <tref title="typed value">typed values</tref> having a datatype of <code>xsd:string</code>,
the <code>@type</code> MUST NOT be set to <code>xsd:string</code> and the resulting value
MUST have only an <code>@value</code> property.</p>
<p>The conversion algorithm takes a single parameter <em>input</em> in the form of an
- array of <tref>Quad</tref> representations.</p>
-
- <p class="issue">This algorithm hasn't been updated to use [[!RDF-CONCEPTS]] yet.</p>
+ array of an <tref>RDF dataset</tref>.</p>
<ol class="algorithm">
<li id="new_graph">Construct <em>defaultGraph</em> as a <tref>JSON object</tref>
@@ -4185,7 +4216,7 @@
<li>Construct <em>graphs</em> as a <tref>JSON object</tref> containing <em>defaultGraph</em>
identified by
an empty <tref>string</tref>.</li>
- <li>For each <tref>quad</tref> in <em>input</em>:
+ <li>For each <tref>triple</tref> in <em>input</em>:
<ol class="algorithm">
<li>Set <em>graph</em> to the entry in <em>graphs</em> identified
by <em>name</em>, initializing it to a new entry using the mechanism
@@ -4196,7 +4227,7 @@
<em>object</em> in <tref>expanded form</tref>, as described in
<a href="#value-expansion">Value Expansion</a>. Add the
resulting <em>object representation</em> to the entry indexed by
- <em>first</em>, and skip to the next <tref>quad</tref>.</li>
+ <em>first</em>, and skip to the next <tref>triple</tref>.</li>
<li>If <em>property</em> is <code>rdf:rest</code>:
<ol class="algorithm">
<li>If <em>object</em> is a <tref>blank node</tref>, use the entry in
@@ -4204,7 +4235,7 @@
to a new <tref>JSON object</tref> if necessary. Add the <em>nominalValue</em> of
<em>object</em> to the entry indexed by <em>rest</em>.
</li>
- <li>Skip to the next <tref>quad</tref>.</li>
+ <li>Skip to the next <tref>triple</tref>.</li>
</ol>
</li>
<li>If <em>name</em> is not <tref>null</tref>, and <em>defaultGraph.nodes</em>
@@ -4375,9 +4406,6 @@
between JSON-LD processors, a JSON-LD serializer MUST NOT backslash-escape forward slashes.</p>
</section>
-<!-- end of RDF algorithms -->
-</section>
-
<!-- end of Algorithms -->
</section>