Add examples
authorGavin Carothers <gavin@carothers.name>
Fri, 10 Jun 2011 16:15:13 -0700
changeset 45 6327d2fb5468
parent 44 9535183efcd5
child 46 3272030cfef3
Add examples
rdf-turtle/examples/example1.ttl
rdf-turtle/examples/example2.ttl
rdf-turtle/examples/example3.ttl
rdf-turtle/index.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rdf-turtle/examples/example1.ttl	Fri Jun 10 16:15:13 2011 -0700
@@ -0,0 +1,10 @@
[email protected] rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
[email protected] dc: <http://purl.org/dc/elements/1.1/> .
[email protected] ex: <http://example.org/stuff/1.0/> .
+
+<http://www.w3.org/TR/rdf-syntax-grammar>
+  dc:title "RDF/XML Syntax Specification (Revised)" ;
+  ex:editor [
+    ex:fullname "Dave Beckett";
+    ex:homePage <http://purl.org/net/dajobe/>
+  ] .
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rdf-turtle/examples/example2.ttl	Fri Jun 10 16:15:13 2011 -0700
@@ -0,0 +1,7 @@
[email protected] : <http://example.org/stuff/1.0/> .
[email protected] rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+:a :b
+  [ rdf:first "apple";
+    rdf:rest [ rdf:first "banana";
+               rdf:rest rdf:nil ]
+  ] .
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rdf-turtle/examples/example3.ttl	Fri Jun 10 16:15:13 2011 -0700
@@ -0,0 +1,7 @@
[email protected] : <http://example.org/stuff/1.0/> .
+
+:a :b "The first line\nThe second line\n  more" .
+
+:a :b """The first line
+The second line
+  more""" .
--- a/rdf-turtle/index.html	Fri Jun 10 16:02:45 2011 -0700
+++ b/rdf-turtle/index.html	Fri Jun 10 16:15:13 2011 -0700
@@ -702,6 +702,65 @@
               </ul>
           </section>
         </section>
+        <section id="sec-examples">
+        <h2>Examples (Informative)</h2>
+
+          <p>This example is a Turtle translation of 
+          <a href="http://www.w3.org/TR/rdf-syntax-grammar/#example7">example 7</a>
+          in the
+          <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML Syntax specification</a>
+          (<a href="examples/example1.ttl">example1.ttl</a>):
+          </p>
+
+          <div data-include="examples/example1.ttl" data-onload="updateExample"/>
+
+
+          <p>An example of an RDF collection of two literals.</p>
+          <pre class="example">
[email protected] : &lt;http://example.org/stuff/1.0/&gt; .
+:a :b ( "apple" "banana" ) .
+          </pre>
+          <p>which is short for (<a href="examples/example2.ttl">example2.ttl</a>):</p>
+
+          <div data-include="examples/example2.ttl" data-onload="updateExample"/>
+
+          <p>An example of two identical triples containing literal objects
+          containing newlines, written in plain and long literal forms.
+          Assumes that line feeds in this document are #xA.
+          (<a href="examples/example3.ttl">example3.ttl</a>):</p>
+
+          <div data-include="examples/example3.ttl" data-onload="updateExample"/>
+
+          <p>As indicated by the grammar, a <a href="#prod-turtle2-collection">collection</a> can be either a <a href="#prod-turtle2-subject">subject</a> or an <a href="#prod-turtle2-object">object</a>. This subject or object will be the novel blank node for the first object, if the collection has one or more objects, or <code>rdf:nil</code> if the collection is empty.</p>
+
+          <p>For example,</p>
+
+          <pre class="query untested">(1 2.0 3E1) :p "w" .</pre>
+
+          <p>is syntactic sugar for (noting that the blank nodes <code>b0</code>, <code>b1</code> and <code>b2</code> do not occur anywhere else in the RDF graph):</p>
+
+<pre class="query untested">    _:b0  rdf:first  1 ;
+          rdf:rest   _:b1 .
+    _:b1  rdf:first  2.0 ;
+          rdf:rest   _:b2 .
+    _:b2  rdf:first  3E1 ;
+          rdf:rest   rdf:nil .
+    _:b0  :p         "w" . </pre>
+
+          <p>RDF collections can be nested and can involve other syntactic forms:</p>
+
+          <pre class="query untested">(1 [:p :q] ( 2 ) ) .</pre>
+
+          <p>is syntactic sugar for:</p><pre class="query untested">    _:b0  rdf:first  1 ;
+          rdf:rest   _:b1 .
+    _:b1  rdf:first  _:b2 .
+    _:b2  :p         :q .
+    _:b1  rdf:rest   _:b3 .
+    _:b3  rdf:first  _:b4 .
+    _:b4  rdf:first  2 ;
+          rdf:rest   rdf:nil .
+    _:b3  rdf:rest   rdf:nil .</pre>
+        </section>
     </body>
 
 </html>