commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r949361 - /websites/production/commonsrdf/content/userguide.html
Date Mon, 27 Apr 2015 16:12:57 GMT
Author: stain
Date: Mon Apr 27 16:12:57 2015
New Revision: 949361

Log:
Site checkin for project Commons RDF

Modified:
    websites/production/commonsrdf/content/userguide.html

Modified: websites/production/commonsrdf/content/userguide.html
==============================================================================
--- websites/production/commonsrdf/content/userguide.html (original)
+++ websites/production/commonsrdf/content/userguide.html Mon Apr 27 16:12:57 2015
@@ -227,6 +227,47 @@
 					<td class="content">
 						<h1>User Guide</h1>
 <p>This page shows some examples of a client using the Commons RDF API. It was last
updated for version <tt>0.1-incubating-SNAPSHOT</tt> of the Commons RDF <a
href="apidocs/">API</a>.</p>
+
+<ul>
+  
+<li><a href="#Using_Commons_RDF_from_Maven">Using Commons RDF from Maven</a></li>
+  
+<li><a href="#Creating_RDFTerm_instances">Creating Commons RDF instances</a></li>
+  
+<li><a href="#Graph">Graph</a></li>
+  
+<li><a href="#Adding_triples">Adding triples</a></li>
+  
+<li><a href="#Finding_triples">Finding triples</a></li>
+  
+<li><a href="#Size">Size</a></li>
+  
+<li><a href="#Iterating_over_triples">Iterating over triples</a></li>
+  
+<li><a href="#Stream_of_triples">Stream of triples</a></li>
+  
+<li><a href="#Removing_triples">Removing triples</a></li>
+  
+<li><a href="#RDF_terms">RDF terms</a></li>
+  
+<li><a href="#IRI">IRI</a></li>
+  
+<li><a href="#Blank_node">Blank node</a>
+  
+<ul>
+    
+<li><a href="#Blank_node_reference">Blank node reference</a></li>
+  </ul></li>
+  
+<li><a href="#Literal">Literal</a>
+  
+<ul>
+    
+<li><a href="#Types">Types</a></li>
+  </ul></li>
+  
+<li><a href="#Triple">Triple</a></li>
+</ul>
 <div class="section">
 <h2><a name="Using_Commons_RDF_from_Maven"></a>Using Commons RDF from Maven</h2>
 <p>To use Commons RDF API from an <a class="externalLink" href="http://maven.apache.org/">Apache
Maven</a> projects, add the following dependency to your <tt>pom.xml</tt>:</p>
@@ -276,7 +317,7 @@
     &lt;/dependency&gt;
 </pre></div></div></div>
 <div class="section">
-<h2><a name="Creating_RDFTerm_instances"></a>Creating RDFTerm instances</h2>
+<h2><a name="Creating_Commons_RDF_instances"></a>Creating Commons RDF instances</h2>
 <p>To create instances of Commons RDF interfaces like <a href="apidocs/org/apache/commons/rdf/api/Graph.html"><tt>Graph</tt></a>
and <a href="apidocs/org/apache/commons/rdf/api/IRI.html"><tt>IRI</tt></a>
you will need a <a href="/apidocs/org/apache/commons/rdf/api/RDFTermFactory.html">RDFTermFactory</a>.</p>
 <p>How to get an instance of this factory is implementation specific, for the <i>simple</i>
implementation, you can construct the <a href="apidocs/org/apache/commons/rdf/simple/SimpleRDFTermFactory.html">SimpleRDFTermFactory</a>:</p>
 
@@ -449,7 +490,7 @@ System.out.println(graph.contains(null,
 <p>false</p>
 </blockquote></div></div>
 <div class="section">
-<h2><a name="IRI_Literal_BlankNode"></a>IRI, Literal, BlankNode</h2>
+<h2><a name="RDF_terms"></a>RDF terms</h2>
 <p>The core RDF terms are arranged in this class hierarchy:</p>
 
 <ul>
@@ -635,10 +676,70 @@ System.out.println(b1.equals(new SimpleR
 <p><i>Note: While it is recommended for this string to be (or contain) a <a
class="externalLink" href="http://docs.oracle.com/javase/8/docs/api/java/util/UUID.html">UUID
string</a>, implementations are free to use any scheme to ensure their blank node references
are globally unique. Therefore no assumptions should be made about this string except that
it is unique per blank node.</i></p></div></div>
 <div class="section">
 <h3><a name="Literal"></a>Literal</h3>
-<p><b>TODO:</b> <a href="apidocs/org/apache/commons/rdf/api/Literal.html">Literal</a></p></div>
+<p>A <a class="externalLink" href="http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal">literal</a>
in RDF is a value such as a string, number or a date. A <tt>Literal</tt> can only
be used as <i>objects</i> of a <tt>Triple</tt></p>
+<p>To create a <a href="apidocs/org/apache/commons/rdf/api/Literal.html">Literal</a>
instance from an <tt>RDFTermFactory</tt>, use <a href="apidocs/org/apache/commons/rdf/api/RDFTermFactory.html#createLiteral-java.lang.String-">createLiteral</a>:</p>
+
+<div class="source">
+<div class="source">
+<pre>Literal literal = factory.createLiteral(&quot;Hello world&quot;);
+System.out.println(literal);
+</pre></div></div>
+
+<blockquote>
+<p><tt>&quot;Hello world&quot;</tt></p>
+</blockquote>
+<p>In RDF 1.1, a <i>plain literal</i> as created above always have the
type <tt>http://www.w3.org/2001/XMLSchema#string</tt>:</p>
+
+<div class="source">
+<div class="source">
+<pre>System.out.println(literal.getDatatype());
+</pre></div></div>
+
+<blockquote>
+<p><tt>&lt;http://www.w3.org/2001/XMLSchema#string&gt;</tt></p>
+</blockquote>
+<p>Literals may be created with an associated language tag:</p>
+
+<div class="source">
+<div class="source">
+<pre>Literal inSpanish = factory.createLiteral(&quot;&#xa1;Hola, Mundo!&quot;,
&quot;es&quot;);
+System.out.println(inSpanish);
+</pre></div></div>
+
+<blockquote>
+<p><tt>&quot;&#xa1;Hola, Mundo!&quot;@es</tt></p>
+</blockquote>
+<p>In RDF 1.1, a Literal with a language always have the type <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</tt>:</p>
+
+<div class="source">
+<div class="source">
+<pre>System.out.println(inSpanish.getDatatype());
+</pre></div></div>
+
+<blockquote>
+<p><tt>&lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#langString&gt;</tt></p>
+</blockquote>
+<p>A <i>typed literal</i> has a datatype represented by an <tt>IRI</tt>:</p>
+
+<div class="source">
+<div class="source">
+<pre>IRI xsdDouble = factory.createIRI(&quot;http://www.w3.org/2001/XMLSchema#double&quot;);
+Literal typedLiteral = factory.createLiteral(&quot;13.37&quot;, xsdDouble);
+System.out.println(typedLiteral);
+</pre></div></div>
+
+<blockquote>
+<p><tt>&quot;13.37&quot;^^&lt;http://www.w3.org/2001/XMLSchema#double&gt;</tt></p>
+</blockquote>
 <div class="section">
-<h3><a name="Types"></a>Types</h3>
-<p><b>TODO:</b> <a href="apidocs/org/apache/commons/rdf/simple/Types.html">Types</a></p></div>
+<h4><a name="Types"></a>Types</h4>
+<p>The class <a href="apidocs/org/apache/commons/rdf/simple/Types.html">Types</a>,
which is part of the <i>simple</i> implementation, provides constants for the
standard XML Schema datatypes, e.g. <tt>xsd:dateTime</tt> and <tt>xsd:float</tt>.
Using <tt>Types</tt>, the above example can be simplified to:</p>
+
+<div class="source">
+<div class="source">
+<pre>Literal typedLiteral = factory.createLiteral(&quot;13.37&quot;, Types.XSD_DOUBLE);
+</pre></div></div>
+<p>Note that the string returned from <tt>Literal.ntriplesString()</tt>
will always contain the full IRI for the datatype.</p></div></div>
 <div class="section">
 <h3><a name="Triple"></a>Triple</h3>
 <p><b>TODO:</b> <a href="apidocs/org/apache/commons/rdf/api/Triple.html">Triple</a></p></div></div>



Mime
View raw message