clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject svn commit: r1824724 - in /clerezza/site/production/getting-started/tutorial/tutorial-03: ./ index.html
Date Mon, 19 Feb 2018 08:54:54 GMT
Author: hasan
Date: Mon Feb 19 08:54:54 2018
New Revision: 1824724

URL: http://svn.apache.org/viewvc?rev=1824724&view=rev
Log:
CLEREZZA-1017: Add Tutorial 03

Added:
    clerezza/site/production/getting-started/tutorial/tutorial-03/
    clerezza/site/production/getting-started/tutorial/tutorial-03/index.html

Added: clerezza/site/production/getting-started/tutorial/tutorial-03/index.html
URL: http://svn.apache.org/viewvc/clerezza/site/production/getting-started/tutorial/tutorial-03/index.html?rev=1824724&view=auto
==============================================================================
--- clerezza/site/production/getting-started/tutorial/tutorial-03/index.html (added)
+++ clerezza/site/production/getting-started/tutorial/tutorial-03/index.html Mon Feb 19 08:54:54
2018
@@ -0,0 +1,349 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <link type="text/css" href="/style/style.css" rel="stylesheet"/>
+        <title>Tutorial 03 - Convert Serialized Graph Representation</title>
+    </head>
+    <body>
+        <div class="zz-header">
+            <div class="bar"></div>
+            <div class="logo">
+                <a href="http://clerezza.apache.org/" style="">
+                    <img src="/images/logo.png" alt="logo"/>
+                </a>
+            </div>
+        </div>
+        <div class="column nav">
+            <ul>
+                <li class="top-nav-entry">
+                    <div class="title">Documentation</div>
+                    <ul class="nav-entries">
+                        <li>
+                            <a href="/getting-started/" class="active">Getting Started</a>
+                        </li>
+                        <li>
+                            <a href="/architecture/">The Apache Clerezza Stack</a>
+                        </li>
+                        <li>
+                            <a href="http://clerezza.apache.org/apidocs/" target="_blank">API
docs</a>
+                        </li>
+                        <li>
+                            <a href="/faq/">FAQ</a>
+                        </li>
+                    </ul>
+                </li>
+                <li class="top-nav-entry">
+                    <div class="title">Project Infos</div>
+                    <ul class="nav-entries">
+                        <li>
+                            <a href="/downloads/">Downloads</a>
+                        </li>
+                        <li>
+                            <a href="/contributing/">Contributing</a>
+                        </li>
+                        <li>
+                            <a href="http://www.apache.org/licenses/" target="_blank">License</a>
+                        </li>
+                        <li>
+                            <a href="/mailinglists/">Mailing lists</a>
+                        </li>
+                        <li>
+                            <a href="http://issues.apache.org/jira/browse/CLEREZZA" target="_blank">Issue
Tracker</a>
+                        </li>
+                        <li>
+                            <a href="https://git-wip-us.apache.org/repos/asf?p=clerezza.git"
target="_blank">Source Repository</a>
+                        </li>
+                    </ul>
+                </li>
+                <li class="top-nav-entry">
+                    <div class="title">Sponsorship</div>
+                    <ul class="nav-entries">
+                        <li>
+                            <a href="/thanks/">Thanks</a>
+                        </li>
+                        <li>
+                            <a href="http://www.apache.org/foundation/sponsorship.html"
target="_blank">Become a Sponsor</a>
+                        </li>
+                        <li>
+                            <a href="http://www.apache.org/foundation/buy_stuff.html"
target="_blank">Buy Stuff</a>
+                        </li>
+                    </ul>
+                </li>
+            </ul>
+        </div>
+        <div class="zz-content">
+            <h1>Tutorial 03 - Convert Serialized Graph Representation</h1>
+            <div class='tx-content'>
+                <div>
+                    <div xmlns="http://www.w3.org/1999/xhtml" class="column one-column">
+                    	<div>
+                    		Author: Hasan (hasan@apache.org)
+                    	</div>
+                    	<div>
+                    		Last update: February 19, 2018
+                    	</div>
+                        <p>
+                        	This tutorial aims at showing how we can use a parser and a serializer
to convert a graph representation from one format to another format.
+                        </p>
+                        <h2>Problem Definition</h2>
+                        <p>
+                        	Given a file containing a set of triples in <a href="https://www.w3.org/TR/turtle/">Turtle</a>
serialization format (text/turtle), another file is to be created containing the same triples
in <a href="https://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a> serialization
format. Assuming the content of the turtle file is as follows:
+                        </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml" class="tx-blockcode">
+@prefix ex: &lt;http://clerezza.apache.org/2017/01/example#&gt; .
+_:a ex:hasFirstName "Hasan" .
+_:a ex:isA ex:ClerezzaUser .
+                        </div>
+                        <p>
+                            the program should create a new file /tmp/example03.rdf containing
the triples in RDF/XML format.
+                        </p>
+                        <h2>Solution</h2>
+                        <p>
+                        	As shown in Tutorial 02, Apache Clerezza provides a Parser that
can be used to read files containing triples in various serialization format. In this tutorial,
we will also use a ParsingProvider based on Jena Parser to parse the turtle file into a Simple
Graph. Afterwards the graph will be serialized using the Apache Clerezza Serializer. The Serializer
makes use of SerializingProvider services which implement the functionality to serialized
graphs to files of specific data format. We are going to use a SerializingProvider based on
Jena Serializer.
+                    	</p>
+                        <p>
+                        	The programme listed below reads the file example03.ttl, parses
its content into a Graph, and serializes the Graph to /tmp/example03.rdf.
+                        </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml" class="tx-blockcode">
+     1  package org.apache.clerezza.tutorial;
+     2  
+     3  import org.apache.clerezza.commons.rdf.Graph;
+     4  import org.apache.clerezza.rdf.core.serializedform.Parser;
+     5  import org.apache.clerezza.rdf.core.serializedform.Serializer;
+     6  import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+     7  import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
+     8  import org.slf4j.Logger;
+     9  import org.slf4j.LoggerFactory;
+    10  
+    11  import java.io.FileNotFoundException;
+    12  import java.io.FileOutputStream;
+    13  import java.io.InputStream;
+    14  
+    15  public class Example03 {
+    16  
+    17      private static final Logger logger = LoggerFactory.getLogger(Example03.class);
+    18  
+    19      public static void main(String[] args) {
+    20          InputStream inputStream = Example03.class.getResourceAsStream("example03.ttl");
+    21          Parser parser = Parser.getInstance();
+    22  
+    23          Graph graph;
+    24          try {
+    25              graph = parser.parse(inputStream, SupportedFormat.TURTLE);
+    26          } catch (UnsupportedFormatException ex) {
+    27              logger.warn(String.format("%s is not supported by the used parser", SupportedFormat.TURTLE));
+    28              return;
+    29          }
+    30  
+    31          Serializer serializer = Serializer.getInstance();
+    32          try {
+    33              FileOutputStream outputStream = new FileOutputStream("/tmp/example03.rdf");
+    34              serializer.serialize(outputStream, graph, SupportedFormat.RDF_XML);
+    35          } catch (FileNotFoundException ex) {
+    36              logger.warn(ex.getMessage());
+    37          } catch (UnsupportedFormatException ex) {
+    38              logger.warn(String.format("%s is not supported by the used serializer",
SupportedFormat.RDF_XML));
+    39          }
+    40      }
+    41  }
+                        </div>
+                        <p>
+                        	We will use maven for building the program. The required POM file
is as follows:
+                    	</p>
+                        <div xmlns="http://www.w3.org/1999/xhtml" class="tx-blockcode">
+     1  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     2    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
+     3    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
+     4    &lt;groupId&gt;org.apache.clerezza.tutorial&lt;/groupId&gt;
+     5    &lt;artifactId&gt;Example-03&lt;/artifactId&gt;
+     6    &lt;packaging&gt;jar&lt;/packaging&gt;
+     7    &lt;version&gt;1.0&lt;/version&gt;
+     8    &lt;build&gt;
+     9      &lt;plugins&gt;
+    10        &lt;plugin&gt;
+    11          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
+    12          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
+    13          &lt;version&gt;3.7.0&lt;/version&gt;
+    14          &lt;configuration&gt;
+    15            &lt;source&gt;1.8&lt;/source&gt;
+    16            &lt;target&gt;1.8&lt;/target&gt;
+    17          &lt;/configuration&gt;
+    18        &lt;/plugin&gt;
+    19        &lt;plugin&gt;
+    20          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
+    21          &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
+    22          &lt;version&gt;1.6.0&lt;/version&gt;
+    23          &lt;executions&gt;
+    24            &lt;execution&gt;
+    25              &lt;goals&gt;
+    26                &lt;goal&gt;java&lt;/goal&gt;
+    27              &lt;/goals&gt;
+    28            &lt;/execution&gt;
+    29          &lt;/executions&gt;
+    30          &lt;configuration&gt;
+    31            &lt;mainClass&gt;org.apache.clerezza.tutorial.Example03&lt;/mainClass&gt;
+    32          &lt;/configuration&gt;
+    33        &lt;/plugin&gt;
+    34      &lt;/plugins&gt;
+    35    &lt;/build&gt;
+    36    &lt;name&gt;Example-03&lt;/name&gt;
+    37    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
+    38    &lt;dependencies&gt;
+    39      &lt;dependency&gt;
+    40        &lt;groupId&gt;org.apache.clerezza&lt;/groupId&gt;
+    41        &lt;artifactId&gt;rdf.core&lt;/artifactId&gt;
+    42        &lt;version&gt;1.0.1&lt;/version&gt;
+    43      &lt;/dependency&gt;
+    44      &lt;dependency&gt;
+    45        &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
+    46        &lt;artifactId&gt;slf4j-simple&lt;/artifactId&gt;
+    47        &lt;version&gt;1.7.25&lt;/version&gt;
+    48      &lt;/dependency&gt;
+    49      &lt;dependency&gt;
+    50        &lt;groupId&gt;org.apache.clerezza&lt;/groupId&gt;
+    51        &lt;artifactId&gt;rdf.jena.parser&lt;/artifactId&gt;
+    52        &lt;version&gt;1.1.1&lt;/version&gt;
+    53      &lt;/dependency&gt;
+    54      &lt;dependency&gt;
+    55        &lt;groupId&gt;org.apache.clerezza&lt;/groupId&gt;
+    56        &lt;artifactId&gt;rdf.jena.serializer&lt;/artifactId&gt;
+    57        &lt;version&gt;1.1.1&lt;/version&gt;
+    58      &lt;/dependency&gt;
+    59    &lt;/dependencies&gt;
+    60  &lt;/project&gt;
+                        </div>
+	                    <p>
+	                    	The directory structure is simple as shown below:
+	                	</p>
+                        <div xmlns="http://www.w3.org/1999/xhtml" class="tx-blockcode">
+    pom.xml
+    src/main/java/org/apache/clerezza/tutorial/Example03.java
+    src/main/resources/org/apache/clerezza/tutorial/example03.ttl
+	                    </div>
+	                    <p>
+	                    	To build the jar, we should invoke:
+	                    </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml" class="tx-blockcode">
+    mvn package
+	                    </div>
+	                    <p>
+	                    	Running the programme can be done by invoking
+	                    </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml" class="tx-blockcode">
+    mvn exec:java
+	                    </div>
+	                    <p>
+	                    	The result of the programme execution is the file /tmp/example03.rdf,
which contains the serialized graph as follows:
+	                    </p>
+                        <div xmlns="http://www.w3.org/1999/xhtml" class="tx-blockcode">
+&lt;rdf:RDF
+    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns:j.0="http://clerezza.apache.org/2017/01/example#" &gt; 
+  &lt;rdf:Description rdf:nodeID="A0"&gt;
+    &lt;j.0:isA rdf:resource="http://clerezza.apache.org/2017/01/example#ClerezzaUser"/&gt;
+    &lt;j.0:hasFirstName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"&gt;Hasan&lt;/j.0:hasFirstName&gt;
+  &lt;/rdf:Description&gt;
+&lt;/rdf:RDF&gt;
+                        </div>
+                        <h2>Discussion</h2>
+                        <p>
+                        	The maven POM file shows four libraries on which the programme directly
depends:
+                    	</p>
+                    	<ul>
+                    		<li>
+                    			org.apache.clerezza.rdf.core: contains implementation of the Apache
Clerezza Parser
+                    		</li>
+                    		<li>
+                    			org.apache.clerezza.rdf.jena.parser: contains ParsingProvider service
based on Jena Parser
+                    		</li>
+                            <li>
+                                org.apache.clerezza.rdf.jena.serializer: contains SerializingProvider
service based on Jena Serializer
+                            </li>
+                    		<li>
+                    			org.slf4j.slf4j-simple: contains implementation of the logger
+                    		</li>
+                    	</ul>
+                        <p>
+                        	The core of the programme lies at line 25 (parsing a stream of triples
into a graph) and 34 (serializing a graph to a file).
+                        </p>
+                        <p>
+                        Note: Any comments and suggestions for improvements are welcome.
Please send your feedback to <a href="mailto:dev@clerezza.apache.org">dev@clerezza.apache.org</a>
+                        </p>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="footer">
+            <div class="logos">
+                <img src="/images/feather.png"/>
+                <img src="/images/sw-vert-w3c.png"/>
+                <img src="/images/footer-logo.png"/>
+            </div>
+            <div class="divider"></div>
+            <div class="dark">
+                <div class="sitemap">
+                    <div class="sitemap-title">Sitemap</div>
+                    <div class="sitemap-content">
+                        <div class="sitemap-column">
+                            <div class="title">Documentation</div>
+                            <ul>
+                                <li>
+                                    <a href="/getting-started/">Getting Started</a>
+                                </li>
+                                <li>
+                                    <a href="/architecture/">The Apache Clerezza Stack</a>
+                                </li>
+                                <li>
+                                    <a href="http://clerezza,apache.org/apidocs/" target="_blank">API
docs</a>
+                                </li>
+                                <li>
+                                    <a href="/faq/">FAQ</a>
+                                </li>
+                            </ul>
+                        </div>
+                        <div class="sitemap-column">
+                            <div class="title">Project Infos</div>
+                            <ul>
+                                <li>
+                                    <a href="/downloads/">Downloads</a>
+                                </li>
+                                <li>
+                                    <a href="/contributing/">Contributing</a>
+                                </li>
+                                <li>
+                                    <a href="http://www.apache.org/licenses/" target="_blank">License</a>
+                                </li>
+                                <li>
+                                    <a href="mailinglists/">Mailing lists</a>
+                                </li>
+                                <li>
+                                    <a href="http://issues.apache.org/jira/browse/CLEREZZA"
target="_blank">Issue Tracker</a>
+                                </li>
+                                <li>
+                                    <a href="https://git-wip-us.apache.org/repos/asf?p=clerezza.git"
target="_blank">Source Repository</a>
+                                </li>
+                            </ul>
+                        </div>
+                        <div class="sitemap-column">
+                            <div class="title">Sponsorship</div>
+                            <ul>
+                                <li>
+                                    <a href="/thanks/">Thanks</a>
+                                </li>
+                                <li>
+                                    <a href="http://www.apache.org/foundation/sponsorship.html"
target="_blank">Become a Sponsor</a>
+                                </li>
+                                <li>
+                                    <a href="http://www.apache.org/foundation/buy_stuff.html"
target="_blank">Buy Stuff</a>
+                                </li>
+                            </ul>
+                        </div>
+                    </div>
+                </div>
+                <div class="copyright">Apache Clerezza, Clerezza, Apache, the Apache
feather logo, and the Apache Clerezza project logo are trademarks of The Apache Software Foundation.
+                    <br></br>© 2011 The Apache Software Foundation.
+                </div>
+            </div>
+        </div>
+    </body>
+</html>
\ No newline at end of file



Mime
View raw message