Skip to content

Commit 25c3828

Browse files
committed
Update fromRdf algorithm to consider list nodes that are in multiple graphs, as considered in json-ld/json-ld.org#357 (comment).
Fixes #13.
1 parent 5457f25 commit 25c3828

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

index.html

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ <h3>Algorithm</h3>
929929
<code>@vocab</code> key.</li>
930930
<li>If <var>value</var> is <a>null</a>, remove
931931
any <a>vocabulary mapping</a> from <var>result</var>.</li>
932-
<li class="changed">Otherewise, if <var>value</var>
932+
<li class="changed">Otherwise, if <var>value</var>
933933
the empty string (<code>&quot;&quot;</code>),
934934
the effective value is the current <a>base IRI</a>.</li>
935935
<li>Otherwise, if <var>value</var> is
@@ -4022,7 +4022,7 @@ <h2>Algorithm</h2>
40224022
<li>Initialize <var>graph map</var> to a <a class="changed">dictionary</a> consisting
40234023
of a single member <code>@default</code> whose value references
40244024
<var>default graph</var>.</li>
4025-
<li>Initialize <var>node usage map</var> to an empty <a class="changed">dictionary</a>.</li>
4025+
<li class="changed">Initialize <var>referenced once</var> to an empty <a>dictionary</a>.</li>
40264026
<li>For each <var>graph</var> in <var>dataset</var>:
40274027
<ol>
40284028
<li>If <var>graph</var> is the <a>default graph</a>,
@@ -4069,19 +4069,24 @@ <h2>Algorithm</h2>
40694069
associated with the <var>predicate</var> member of <var>node</var>, append a
40704070
reference to <var>value</var> to the <a>array</a>. Two JSON objects
40714071
are considered equal if they have equivalent key-value pairs.</li>
4072-
<li>If <var>object</var> is a <a>blank node identifier</a> or <a>IRI</a>,
4073-
it might represent the list node:
4072+
<li class="changed">If <var>object</var> is <code>rdf:nil</code>, it represents
4073+
the termination of an <a>RDF collection</a>:
40744074
<ol>
4075-
<li>If the <var>object</var> member of <var>node usage map</var> does not exist,
4076-
initialize it to a new empty <a>array</a>.</li>
4077-
<li>Append the value of the <code>@id</code> member of <code>node</code> to
4078-
the <var>object</var> member of <var>node usage map</var>.</li>
4079-
<li>If the <var>object</var> member of <var>node map</var> has no
4080-
<code>usages</code> member, create one and initialize it to
4081-
an empty <a>array</a>.</li>
40824075
<li>Reference the <code>usages</code> member of the <var>object</var>
40834076
member of <var>node map</var> using the variable <var>usages</var>.</li>
4084-
<li>Append a new <a class="changed">dictionary</a> consisting of three
4077+
<li>Append a new <a>dictionary</a> consisting of three
4078+
members, <code>node</code>, <code>property</code>, and <code>value</code>
4079+
to the <var>usages</var> <a>array</a>. The <code>node</code> member
4080+
is set to a reference to <var>node</var>, <code>property</code> to <var>predicate</var>,
4081+
and <code>value</code> to a reference to <var>value</var>.</li>
4082+
</ol>
4083+
</li>
4084+
<li class="changed">Otherwise, if <var>referenced once</var> has an entry for <var>object</var>,
4085+
set the <var>object</var> member of <var>referenced once</var> to <code>false</code>.</li>
4086+
<li class="changed">Otherwise, if <var>object</var> is a <a>blank node identifier</a>,
4087+
it might represent a list node:
4088+
<ol>
4089+
<li>Set the <var>object</var> member of <var>referenced once</var> to a new <a>dictionary</a> consisting of three
40854090
members, <code>node</code>, <code>property</code>, and <code>value</code>
40864091
to the <var>usages</var> <a>array</a>. The <code>node</code> member
40874092
is set to a reference to <var>node</var>, <code>property</code> to <var>predicate</var>,
@@ -4112,11 +4117,8 @@ <h2>Algorithm</h2>
41124117
<li>While <var>property</var> equals <code>rdf:rest</code>,
41134118
<span class="changed">the value of the <code>@id</code> member
41144119
of <var>node</var> is a <a>blank node identifier</a>,</span>
4115-
the <a>array</a> value of the member of <var>node usage map</var> associated with the <code>@id</code>
4116-
member of <code>node</code> has only one member,
4117-
<span class="changed">
4118-
the value associated to the <code>usages</code> member of <i>node</i> has
4119-
exactly 1 entry,</span>
4120+
the value of the member of <var>referenced once</var> associated with the <code>@id</code>
4121+
member of <code>node</code> is a <a>dictionary</a>,
41204122
<var>node</var> has a <code>rdf:first</code> and <code>rdf:rest</code> property,
41214123
both of which have as value an <a>array</a> consisting of a single element,
41224124
and <var>node</var> has no other members apart from an optional <code>@type</code>
@@ -4129,8 +4131,8 @@ <h2>Algorithm</h2>
41294131
<var>node</var> to the <var>list</var> <a>array</a>.</li>
41304132
<li>Append the value of the <code>@id</code> member of
41314133
<var>node</var> to the <var>list nodes</var> <a>array</a>.</li>
4132-
<li>Initialize <var>node usage</var> to the only item of the
4133-
<code>usages</code> member of <var>node</var>.</li>
4134+
<li>Initialize <var>node usage</var> to the value of the member of <var>referenced once</var> associated with the <code>@id</code>
4135+
member of <code>node</code>.</li>
41344136
<li>Set <var>node</var> to the value of the <code>node</code> member
41354137
of <var>node usage</var>, <var>property</var> to the value of the
41364138
<code>property</code> member of <var>node usage</var>, and

0 commit comments

Comments
 (0)