RDF/XML example annotated
authorGuus Schreiber <guus.schreiber@vu.nl>
Sun, 16 Feb 2014 23:02:25 +0100
changeset 1916 60fb6507cb48
parent 1915 a81d4f8e99ab
child 1917 d67815dc364e
RDF/XML example annotated
rdf-primer/index.html
--- a/rdf-primer/index.html	Sun Feb 16 18:35:27 2014 +0100
+++ b/rdf-primer/index.html	Sun Feb 16 23:02:25 2014 +0100
@@ -1135,18 +1135,15 @@
 <h2>Examples of RDF syntaxes</h2>
    
 <p>In <a href="#section-graph-syntax">Sec. 5</a> the
-different concrete syntaxes of RDF are briefly described. Examples are
-given only of the Turtle and TriG syntax. This appendix lists
-corresponding examples for the other syntaxes listed. The
-single-graph examples encode the same graph as in
-<a href="#fig4">Fig.&nbsp;4</a>;
-the mutiple-graphs examples encode the same graph as in
-<a href="#fig5">Fig.&nbsp;5</a>. </p>
+different concrete syntaxes of RDF are briefly described.
+This appendix lists
+corresponding examples for two other RDF syntaxes, namely RDFa and
+RDF/XML. Also, more elaborate examples of JSON-LD are included.</p>
 
 <section id="subsection-rdfa"> 
 <h3>RDFa</h3>
 
-<p>RDFa [[RDFA-PRIMER]] is an RDF syntax for encoding RDF
+<p>RDFa is an RDF syntax for encoding RDF
 triples in an HTML document. The HTML example below encodes the
 RDF graph depicted in <a href="#fig4">Fig.&nbsp;4</a>:</p>
   
@@ -1154,45 +1151,47 @@
 01    &lt;div about="http://example.org/bob#me" typeof="http://xmlns.com/foaf/0.1/Person"&gt;
 02      &lt;p&gt;
 03        Bob knows &lt;a rel="http://xmlns.com/foaf/0.1/knows" href="http://example.org/alice#me"&gt;Alice&lt;/a&gt;
-04        and was born on the
-05        &lt;span property="http://schema.org/birthDate" datatype="http://www.w3.org/2001/XMLSchema#date"&gt;1990-07-04&lt;/span&gt;.
+04        and was born on the &lt;span property="http://schema.org/birthDate"
+05        datatype="http://www.w3.org/2001/XMLSchema#date"&gt;1990-07-04&lt;/span&gt;.
 06      &lt;/p&gt;
 07      &lt;p&gt;
-08        Bob is interested in &lt;a rel="http://xmlns.com/foaf/0.1/topic_interest" href="http://www.wikidata.org/entity/Q12418"&gt;the Mona Lisa&lt;/a&gt;.
-09      &lt;/p&gt;
-10    &lt;/div&gt;
-11    &lt;div about="http://www.wikidata.org/entity/Q12418"&gt;
-12      &lt;p&gt;
-13        The &lt;span property="http://purl.org/dc/terms/title"&gt;Mona Lisa&lt;/span&gt;
-14        was painted by
-15        &lt;a rel="http://purl.org/dc/terms/creator" href="http://dbpedia.org/resource/Leonardo_da_Vinci"&gt;Leonardo da Vinci&lt;/a&gt;
-16        and is the subject of the video
-17        &lt;a rev="http://purl.org/dc/terms/subject" href="http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619"&gt;'La Joconde à Washington'&lt;/a&gt;.
-18      &lt;/p&gt;
-19    &lt;/div&gt;
-      </pre>
+08        Bob is interested in &lt;a rel="http://xmlns.com/foaf/0.1/topic_interest"
+09          href="http://www.wikidata.org/entity/Q12418"&gt;the Mona Lisa&lt;/a&gt;.
+10      &lt;/p&gt;
+11    &lt;/div&gt;
+12    &lt;div about="http://www.wikidata.org/entity/Q12418"&gt;
+13      &lt;p&gt;
+14        The &lt;span property="http://purl.org/dc/terms/title"&gt;Mona Lisa&lt;/span&gt;
+15        was painted by &lt;a rel="http://purl.org/dc/terms/creator"
+16        href="http://dbpedia.org/resource/Leonardo_da_Vinci"&gt;Leonardo da Vinci&lt;/a&gt;
+17        and is the subject of the video &lt;a rev="http://purl.org/dc/terms/subject"
+18        href="http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619"&gt;
+19        'La Joconde à Washington'&lt;/a&gt;.
+20      &lt;/p&gt;
+21    &lt;/div&gt;
+</pre>
 
 <p>RDFa introduces a number special attributes that enable the
 specification of triples within HTML. For example, the <code>div</code> elements 
-in lines 1 and 11 have an <code>about</code> 
+in lines 1 and 12 have an <code>about</code> 
 attribute, specifying the IRI about which RDF statements can be made within this
-block. In line 3 we see a <code>rel</code> ("relation") attribute that an RDFa
--aware processor should interpret as an RDF property IRI. The
+block. In line 3 we see a <code>rel</code> ("relation") attribute that
+an RDFa-aware processor should interpret as an RDF property IRI. The
 <code>href</code> attribute value is the object of the triple. Th
 result is the triple: <p>
 
-<p class="example">
+<pre class="example">
 &lt;http://example.org/bob#me&gt; &lt;http://xmlns.com/foaf/0.1/knows&gt; &lt;http://example.org/alice#me&gt; .
-</p>
+</pre>
 
 <p>The <code>rel</code> is used in cases where the object is an
 IRI. Two more examples are found in lines 8 and 15. If the object of
 the triple is a literal, then RDFa uses the
 <code>property</code> attribute to specify the RDF property IRI. Lines
-5 and 13 contain examples of such triples. A <code>datatype</code>
+4-5 and 14 contain examples of such triples. A <code>datatype</code>
 attribute is used to indicate the datatype of the literal (line 5). If
 no datatype or language tag is specified the literal is assumed to
-have the datatype <code>xsd:string</code> (line 13). </p>
+have the datatype <code>xsd:string</code> (line 14). </p>
 
 <p>Two more RDFa attributes appear in the example. The
 <code>typeof</code> attribute in line 1 is similar to the Turtle
@@ -1202,62 +1201,74 @@
 order: the "about" IRI is the object of the triple; the "href"
 attribute specifies the subject. </p>
 
-<p>The RDFa Primer provides detailed information about RDFa [[RDFA-PRIMER]]. Below shows the HTML rendered from the example:</p>
-
-<blockquote>
-<div about="http://example.org/bob#me" typeof="http://xmlns.com/foaf/0.1/Person">
-    <p>
-      Bob knows <a rel="http://xmlns.com/foaf/0.1/knows" href="http://example.org/alice#me">Alice</a>
-      and was born on the
-      <span property="http://schema.org/birthDate" datatype="http://www.w3.org/2001/XMLSchema#date">1990-07-04</span>.
-    </p>
-    <p>
-      Bob is interested in <a rel="http://xmlns.com/foaf/0.1/topic_interest" href="http://www.wikidata.org/entity/Q12418">the Mona Lisa</a>.
-    </p>
-  </div>
-  <div about="http://www.wikidata.org/entity/Q12418">
-    <p>
-      The <span property="http://purl.org/dc/terms/title">Mona Lisa</span>
-      was painted by
-      <a rel="http://purl.org/dc/terms/creator" href="http://dbpedia.org/resource/Leonardo_da_Vinci">Leonardo da Vinci</a>
-      and is the subject of the video
-      <a rev="http://purl.org/dc/terms/subject" href="http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619">'La Joconde à Washington'</a>.
-    </p>
-  </div>
-</blockquote>
-
+<p>For more information consult the RDFa Primer [[RDFA-PRIMER]] for detailed information about RDFa. </p>
 
-<!--      <p>Single-graph example:</p>
-      <pre class="example" id="rdfa-example">
-01    &lt;div prefix="
-02      rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
-03      foaf: http://xmlns.com/foaf/0.1/
-04      wd: http://www.wikidata.org/entity/
-05      dcterms: http://purl.org/dc/terms/
-06      xsd: http://www.w3.org/2001/XMLSchema#"&gt;
-07        &lt;div typeof="foaf:Person" about="http://example.org/bob#me"&gt;
-08          &lt;p&gt;
-09            Bob knows &lt;a rel="foaf:knows" href="http://example.org/alice#me"&gt;Alice&lt;/a&gt;
-10            and was born on the &lt;span property="schema:birthDate" datatype="xsd:date"&gt;1990-07-04&lt;/span&gt;.
-11          &lt;/p&gt;
-12          &lt;p&gt;
-13            Bob is interested in &lt;a rel="foaf:topic_interest" resource="wd:Q12418"&gt;the Mona Lisa&lt;/a&gt;.
-14          &lt;/p&gt;
-15          &lt;div about="wd:Q12418"&gt;
-16            The &lt;span property="dcterms:title"&gt;Mona Lisa&lt;/span&gt; was painted by &lt;a rel="dcterms:creator" href="http://dbpedia.org/resource/Leonardo_da_Vinci"&gt;Leonardo da Vinci&lt;/a&gt;
-17            and is the subject of the video &lt;a rev="dcterms:subject" href="http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619"&gt;'La Joconde à Washington'&lt;/a&gt;.
-18          &lt;/div&gt;
-19      &lt;/div&gt;
-20    &lt;/div&gt;
-      </pre>
--->
+</section>
 
-
-    </section>
+<section id="subsection-rdf-xml">
 
-    <section id="subsection-jsonld">
+<h3>RDF/XML</h3>
 
-       <h3>JSON-LD</h3>
+<p>RDF/XML [[RDF-XML]] is an XML syntax for RDFD. When RDF was original developed in the late 1990s, RDF/XML was its only syntax for RDF. RDF/XML. The RDF/XML example below encodes the
+RDF graph depicted in <a href="#fig4">Fig.&nbsp;4</a>:</p>
+
+<pre class="example" id="rdf-xml-example">
+01    &lt;?xml version="1.0" encoding="utf-8"?&gt;
+02    &lt;rdf:RDF
+03         xmlns:dcterms="http://purl.org/dc/terms/"
+04         xmlns:foaf="http://xmlns.com/foaf/0.1/"
+05         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+06         xmlns:schema="http://schema.org/"&gt;
+07      &lt;rdf:Description rdf:about="http://example.org/bob#me"&gt;
+08        &lt;rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/&gt;
+09        &lt;schema:birthDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date"&gt;1990-07-04&lt;/schema:birthDate&gt;
+10        &lt;foaf:knows rdf:resource="http://example.org/alice#me"/&gt;
+11        &lt;foaf:topic_interest rdf:resource="http://www.wikidata.org/entity/Q12418"/&gt;
+12      &lt;/rdf:Description&gt;
+13      &lt;rdf:Description rdf:about="http://www.wikidata.org/entity/Q12418"&gt;
+14        &lt;dcterms:title&gt;Mona Lisa&lt;/dcterms:title&gt;
+15        &lt;dcterms:creator rdf:resource="http://dbpedia.org/resource/Leonardo_da_Vinci"/&gt;
+16      &lt;/rdf:Description&gt;
+17      &lt;rdf:Description rdf:about="http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619"&gt;
+18        &lt;dcterms:subject rdf:resource="http://www.wikidata.org/entity/Q12418"/&gt;
+19      &lt;/rdf:Description&gt;
+20    &lt;/rdf:RDF&gt;
+</pre>
+
+<p>In RDF/XML RDF triples are specified within an XML element
+<code>rdf:RDF</code> (lines 2 and 20). The attributes of the
+<code>rdf:RDF</code> start tag (lines 3-6) provide a shorthand for writing down
+names of XML elements and attributes. The XML element
+<code>rdf;Description</code> (short for
+<code>http://www.w3.org/1999/02/22-rdf-syntax-ns#Description</code>)
+is used to define sets of triples, in which the subject is the IRI
+specified in the <code>about</code> attribute.  The first description
+block (line 7-12) has four sub-elements. The name of the subelement is
+the property IRI, e.g., <code>rdf:type</code> (line 8). Here, each
+subelement represents one triple. In case the object is also an IRI
+the property subelement has no content and 
+the object IRI is specified using the <code>rdf;resource</code>
+attribute (lines 8, 10-11, 15 and 18). In case the object of the
+triple is a literal the literal value is given as content of the
+property element (lines 9 and 14). The datatype is specified as
+attribute of the property element (line 9). If the datatype is
+omitted (line 14) and no language tag is present the literal is
+considered to have the default datatype <code>xsd:string</code>.
+
+<p>The example shows the baseline syntax; please consult the RDF/XML
+document [[RDF-XML for a more in-depth treatment of the syntax. It
+might seem strange that the attribute values contain full IRIs,
+despite the fact that for some of these namespace prefixes were
+defined. This is because these prefixes can only be used for XML
+element and attribute names. In practice, developers use XML entity
+declarations to provide also shorthands for attribute vales. </p>
+
+</section>
+
+  
+<section id="subsection-jsonld">
+
+<h3>JSON-LD</h3>
 
       Single-graph example:
 
@@ -1464,38 +1475,9 @@
 
     </section>
 
-    <section id="subsection-rdf-xml">
-
-    <h3>RDF/XML</h3>
-
-    <p>Single-graph example:</p>
 
-      <pre class="example" id="rdf-xml-example">
-01    &lt;?xml version="1.0" encoding="utf-8"?&gt;
-02    &lt;rdf:RDF
-03       xmlns:dcterms="http://purl.org/dc/terms/"
-04       xmlns:foaf="http://xmlns.com/foaf/0.1/"
-05       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-06       xmlns:schema="http://schema.org/"
-07       xmlns:wd="http://www.wikidata.org/entity/"
-08       xmlns:xsd="http://www.w3.org/2001/XMLSchema#"&gt;
-09      &lt;foaf:Person rdf:about="http://example.org/bob#me"&gt;
-10        &lt;schema:birthDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date"&gt;1990-07-04&lt;/schema:birthDate&gt;
-11        &lt;foaf:knows rdf:resource="http://example.org/alice#me"/&gt;
-12        &lt;foaf:topic_interest rdf:resource="http://www.wikidata.org/entity/Q12418"/&gt;
-13      &lt;/foaf:Person&gt;
-14      &lt;rdf:Description rdf:about="http://www.wikidata.org/entity/Q12418"&gt;
-15        &lt;dcterms:title&gt;Mona Lisa&lt;/dcterms:title&gt;
-16        &lt;dcterms:creator rdf:resource="http://dbpedia.org/resource/Leonardo_da_Vinci"/&gt;
-17      &lt;/rdf:Description&gt;
-18      &lt;rdf:Description rdf:about="http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619"&gt;
-19        &lt;dcterms:subject rdf:resource="http://www.wikidata.org/entity/Q12418"/&gt;
-20      &lt;/rdf:Description&gt;
-21    &lt;/rdf:RDF&gt;
-      </pre>
 
-    </section>
-    </section>
+</section>
    
 
   </body>