Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON-LD to RDF algorithm to csv2rdf and update references. #326

Merged
merged 2 commits into from
Mar 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 68 additions & 12 deletions csv2rdf/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ <h3>Algorithm terms</h3>
<dd>A <a href="http://www.w3.org/TR/tabular-data-model/#dfn-column" class="externalDFN">column</a> is defined in [[!tabular-data-model]] as a vertical arrangement of <a title="cell">cells</a> within a <a title="annotated table">table</a>.</dd>

<dt><dfn>common properties</dfn></dt>
<dd>The <a>common properties</a> of a metadata resource are defined in <a href="http://www.w3.org/TR/tabular-metadata/#common-properties">Section 3.3 Common Properties</a> of [[!tabular-metadata]]). The RDF values of these properties are the result of running the [[!json-ld-api]] <cite><a href="http://www.w3.org/TR/json-ld-api/#deserialize-json-ld-to-rdf-algorithm">toRdf</a></cite> algorithm over the <a>common properties</a> defined within the metadata description.</dd>

<dd class="issue" data-number="288">“Create simplified algorithm for turning normalized JSON-LD into RDF”: once that is done, the reference to the <code>toRdf</code> algorithm should be replaced.</dd>

<dd>The <a>common properties</a> of a metadata resource are defined in <a href="http://www.w3.org/TR/tabular-metadata/#common-properties">Section 3.3 Common Properties</a> of [[!tabular-metadata]]). The RDF triples corresponding to these properties are the result of running the algorithm specified in <a href="#json-ld-to-rdf" class="sectionRef"></a> or equivalalent, over the <a>common properties</a> defined within the metadata description.</dd>

<dt><dfn>identifier</dfn></dt>
<dd>The identifier is the evaluation of the <code>@id</code> property for the current resource. As defined in [[!tabular-data-model]], the <a>identifier</a> is <code>null</code> if the <code>@id</code> property is undefined. The <a>identifier</a> MAY be applied to either a <a href="http://www.w3.org/TR/tabular-data-model/#dfn-group-of-tables" class="externalDFN">table group</a> or a <a href="http://www.w3.org/TR/tabular-data-model/#dfn-annotated-table" class="externalDFN">table</a>.</dd>
Expand All @@ -203,6 +200,9 @@ <h3>Algorithm terms</h3>
<dt><dfn>notes</dfn></dt>
<dd>A list of <a href="http://www.w3.org/TR/tabular-data-model/#dfn-table-notes" class="externalDFN">notes</a>, as defined in [[!tabular-data-model]], attached to an <a title="annotated table">annotated table</a> using the <code>notes</code> property. This may be an empty list.</dd>

<dt><dfn>prefixed name</dfn></dt>
<dd>A <a href="http://www.w3.org/TR/json-ld/#dfn-compact-iri" class="externalDFN">prefixed name</a> is an abbreviation for a URI, in the syntax <code><var>prefix</var>:<var>name</var></code>. See <cite><a href="http://w3c.github.io/csvw/metadata/#names-of-common-properties">Names of Common Properties</a></cite> in [[!tabular-metadata]] for information on expansion.</dd>

<dt><dfn>propertyUrl</dfn></dt>
<dd>The <a>propertyUrl</a> is the evaluation of the <code>propertyUrl</code> property of the current <a href="http://www.w3.org/TR/tabular-data-model/#dfn-cell" class="externalDFN">cell</a> as defined in <cite><a href="http://www.w3.org/TR/tabular-metadata/#dfn-uri-template-property">URI template properties</a></cite> in [[!tabular-metadata]].</dd>

Expand Down Expand Up @@ -255,8 +255,7 @@ <h3>Generating RDF</h3>
</dl>
</li>
<li>
<p>In <strong><a>standard mode</a></strong> only, recursively insert the triples resulting from running the [[!json-ld-api]] <cite><a href="http://www.w3.org/TR/json-ld-api/#deserialize-json-ld-to-rdf-algorithm">toRdf</a></cite> algorithm over any <a>common properties</a> specified for the <a>table group</a>, with <a>node</a> <var>G</var> as an initial <a>subject</a>.</p>
<p>Where where language information is specified within the metadata description the appropriate <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-language-tag" class="externalDFN">language tag(s)</a> (as defined in [[!rdf11-concepts]]) MUST be provided.</p>
<p>In <strong><a>standard mode</a></strong> only, emit the triples generated by running the algorithm specified in <a href="#json-ld-to-rdf" class="sectionRef"></a> over any <a>common properties</a> specified for the <a>table group</a>, with <a>node</a> <var>G</var> as an initial <var>subject</var>, the <a title="common properties">common property</a> as <var>property</var>, and the value of the <a title="common properties">common property</a> as <var>value</var>.</p>
</li>
<li>
<p>Each <a title="annotated table">table</a> is processed sequentially in the order they are referenced in the <a>table group description</a>.</p>
Expand Down Expand Up @@ -289,12 +288,7 @@ <h3>Generating RDF</h3>
</dl>
</li>
<li>
<p>In <strong><a>standard mode</a></strong> only, recursively insert the triples resulting from running the [[!json-ld-api]] <cite><a href="http://www.w3.org/TR/json-ld-api/#deserialize-json-ld-to-rdf-algorithm">toRdf</a></cite> algorithm over any <a>notes</a> and <a>common properties</a> specified for the <a title="annotated table">table</a>, with <a>node</a> <var>T</var> as an initial <a>subject</a>.</p>

<p class="issue" data-number="288">“Create simplified algorithm for turning normalized JSON-LD into RDF”: once that is done, the reference to the <code>toRdf</code> algorithm should be replaced.</p>


<p>Where where language information is specified within the metadata description for <a>notes</a> or <a>common properties</a> the appropriate <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-language-tag" class="externalDFN">language tag(s)</a> (as defined in [[!rdf11-concepts]]) MUST be provided.</p>
<p>In <strong><a>standard mode</a></strong> only, emit the triples generated by running the algorithm specified in <a href="#json-ld-to-rdf" class="sectionRef"></a> over any <a>notes</a> and <a>common properties</a> specified for the <a title="annotated table">table</a>, with <a>node</a> <var>T</var> as an initial <var>subject</var>, the <a>notes</a> or <a title="common properties">common property</a> as <var>property</var>, and the value of the <a title="common properties">common property</a> as <var>value</var>.</p>

<p class="note">All other annotations for the <a title="annotated table">table</a> are ignored during the conversion; including information about <a href="http://www.w3.org/TR/tabular-metadata/#dfn-tableschema" class="externalDFN">table schemas</a> and <a href="http://www.w3.org/TR/tabular-metadata/#dfn-column-description" class="externalDFN">column descriptions</a> specified therein, <a href="http://www.w3.org/TR/tabular-metadata/#dfn-dialect-description" class="externalDFN">dialect descriptions</a>, <a href="http://www.w3.org/TR/tabular-metadata/#dfn-foreign-key-definition" class="externalDFN">foreign-key-definitions</a> etc.</p>
</li>
Expand Down Expand Up @@ -532,6 +526,68 @@ <h2>Inclusion of provenance information</h2>
</pre>
</section>

<section>
<h3>JSON-LD to RDF</h3>
<p>This section defines a mechanism for transforming the JSON-LD Dialect used for <a>common properties</a> and <a><code>notes</code></a> into RDF in a manner consistent with the <cite><a href="http://www.w3.org/TR/json-ld-api/#deserialize-json-ld-to-rdf-algorithm">Deserialize JSON-LD to RDF Algorithm</a></cite> defined in [[!json-ld-api]]. Converters MAY use any algorithm which results in equivalent triples.</p>
<p>Given a <var>subject</var>, <var>property</var> and <var>value</var> in <a href="http://w3c.github.io/csvw/metadata/#dfn-normalization">normalized</a> form:</p>
<ol class="algorithm">
<li><var>Property</var> is a <a href="http://www.w3.org/TR/json-ld/#dfn-term" class="externalDFN">term</a> defined in the [[csvw-context]], a <a>prefixed name</a>, or an absolute URL; expand to an absolute URL by replacing a <a href="http://www.w3.org/TR/json-ld/#dfn-term" class="externalDFN">term</a> with the URI from the term definition in [[csvw-context]] or a <a>prefixed name</a> as described in <a href="#names-of-common-properties" class="sectionRef"></a>.</li>
<li>If <var>value</var> is an array, generate RDF by running this algorithm using <var>subject</var>, <var>property</var> using each array member as <var>value</var>.</li>
<li>If <var>value</var> is an object containing <code>@value</code>, create an RDF Literal <var>lit</var> using the string value of <code>@value</code> and language from <code>@language</code>, if present, and emit the following triple:
<dl class="triple">
<dt>subject</dt>
<dd><a>node</a> <var>subject</var></dd>
<dt>predicate</dt>
<dd><var>property</var></dd>
<dt>object</dt>
<dd><a>literal node</a> <var>lit</var></dd>
</dl>
</li>
<li>Otherwise, if <var>value</var> is an object:
<ol class="algorithm">
<li>Establish a new <a>node</a> <var>S</var> from the value of <code>@id</code>, if it exists, and new <a>blank node</a> otherwise and emit the following triple:
<dl class="triple">
<dt>subject</dt>
<dd><a>node</a> <var>subject</var></dd>
<dt>predicate</dt>
<dd><a>node</a> <var>property</var></dd>
<dt>object</dt>
<dd><a>node</a> <var>S</var></dd>
</dl>
</li>
<li>For every value of <code>@type</code>, either a <a href="http://www.w3.org/TR/json-ld/#dfn-term" class="externalDFN">term</a> defined in the [[csvw-context]], a <a>prefixed name</a>, or an absolute URL; establish a new node <var>T<sub>i</sub></var> by expanding the value to an absolute URL by replacing a <a href="http://www.w3.org/TR/json-ld/#dfn-term" class="externalDFN">term</a> with the URI from the term definition in [[csvw-context]] or a <a>prefixed name</a> with its expanded value. For each <var>T<sub>i</sub></var>, emit the following triple:
<dl class="triple">
<dt>subject</dt>
<dd><a>node</a> <var>S</var></dd>
<dt>predicate</dt>
<dd><code>rdf:type</code></dd>
<dt>object</dt>
<dd><a>node</a> <var>T<sub>i</sub></var></dd>
</dl>
</li>
<li>For every <var>key</var> and <var>val</var> from <var>value</var> that does not start with <code>@</code> (<code>U+0040</code>) generate RDF by running this algorithm using <var>S</var> for <var>subject</var>, <var>key</var> for <var>property</var> and <var>val</var> for <var>value</var>.
</li>
</ol>
</li>
<li>Otherwise, establish <var>lit</var> as an RDF Literal as follows:
<ol class="algorithm">
<li>If <var>value</var> is <code>true</code> or <code>false</code>, create an RDF Literal <var>lit</var> using the strings "true" or "false", accordingly with datatype <code>xsd:boolean</code></li>
<li>Otherwise, if <var>value</var> is a JSON number with a non-zero fractional part, create an RDF Literal <var>lit</var> using the canonical representation for <var>value</var> with datatype <code>xsd:double</code>.</li>
<li>Otherwise, if <var>value</var> is a JSON number with no non-zero fractional part, create an RDF Literal <var>lit</var> using the canonical representation for <var>value</var> with datatype <code>xsd:integer</code>.</li>
</ol>
<p>Emit the following triple:
<dl class="triple">
<dt>subject</dt>
<dd><a>node</a> <var>subject</var></dd>
<dt>predicate</dt>
<dd><var>property</var></dd>
<dt>object</dt>
<dd><a>literal node</a> <var>lit</var></dd>
</dl>
</p>
</ol>
</section>

<section id="examples" class="informative">
<h2>Examples</h2>
<p>In addition to the namespaces defined <a href="#conformance">above</a>, the examples provided here make use of the following namespaces:</p>
Expand Down