Author: wikier
Date: Wed Apr 24 16:44:54 2013
New Revision: 1471527

URL: http://svn.apache.org/r1471527
Log:
added additional information for ldpath template

Added:
    incubator/marmotta/site/trunk/content/markdown/ldpath/template.md.vm
      - copied, changed from r1471397, 
incubator/marmotta/site/trunk/content/markdown/ldpath/template.md
Removed:
    incubator/marmotta/site/trunk/content/markdown/ldpath/template.md

Copied: incubator/marmotta/site/trunk/content/markdown/ldpath/template.md.vm 
(from r1471397, 
incubator/marmotta/site/trunk/content/markdown/ldpath/template.md)
URL: 
http://svn.apache.org/viewvc/incubator/marmotta/site/trunk/content/markdown/ldpath/template.md.vm?p2=incubator/marmotta/site/trunk/content/markdown/ldpath/template.md.vm&p1=incubator/marmotta/site/trunk/content/markdown/ldpath/template.md&r1=1471397&r2=1471527&rev=1471527&view=diff
==============================================================================
--- incubator/marmotta/site/trunk/content/markdown/ldpath/template.md (original)
+++ incubator/marmotta/site/trunk/content/markdown/ldpath/template.md.vm Wed 
Apr 24 16:44:54 2013
@@ -4,12 +4,6 @@ LDPath implements an extension of the [F
 template engine that allows constructing templates with LDPath statements for 
inserting 
 and iterating over values.
 
-## Usage
-
-This is the basic Java code you may need to write:
-
-    @@TODO
-
 ## Template example
 
     <@namespace rdfs="http://www.w3.org/2000/01/rdf-schema#"; />
@@ -36,3 +30,32 @@ This is the basic Java code you may need
 
     </html>
 
+## Usage
+
+To use this templating mechanism you would need to include the following 
artifact 
+in your Maven build file:
+
+    <dependency>
+        <groupId>org.apache.marmotta</groupId>
+        <artifactId>ldpath-template</artifactId>
+        <version>${projectVersion}</version>
+    </dependency>
+
+This is the basic Java code for rendering LDPath templates:
+
+    final RepositoryConnection conn = ...getConnection();
+    try {
+        conn.begin();
+        final URI subject = conn.getValueFactory().createURI(uri);
+
+        final SesameConnectionBackend backend = 
SesameConnectionBackend.withConnection(conn);
+        final TemplateEngine<Value> engine = new 
TemplateEngine<Value>(backend);            
+        engine.setDirectoryForTemplateLoading(new File("/path/to/templates"));
+
+        OutputStreamWriter writer = new OutputStreamWriter(System.out, 
Charset.forName("utf-8"));
+        engine.processFileTemplate(subject, "example.ftl", writer);
+    } finally {
+        conn.commit();
+        conn.close();
+    }
+


Reply via email to