You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2013/02/19 13:57:40 UTC

[2/11] added missing module from the previous code importation

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml b/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml
new file mode 100644
index 0000000..ac80657
--- /dev/null
+++ b/ldpath/ldpath-functions-xml/src/test/resources/xml/quiz.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright (c) 2013 Salzburg Research.
+  ~
+  ~  Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<!-- All changes here should be reflected in the actual test-data file data.n3 -->
+<quiz>
+    <!-- Selected questions from http://www.sciencekids.co.nz/quizzes.html -->
+    <question category="earth">
+        <qline>What is the name of the largest ocean on earth?</qline>
+        <answers>
+            <answer correct="true">The Pacific Ocean</answer>
+            <answer>The Atlantic Ocean</answer>
+            <answer>The Indian Ocean</answer>
+        </answers>
+    </question>
+    <question category="earth">
+        <qline>What do you call molten rock before it has erupted?</qline>
+        <answers>
+            <answer correct="true">Magma</answer>
+            <answer>Lava</answer>
+            <answer>Hot-Stone</answer>
+        </answers>
+    </question>
+    <question category="earth">
+        <qline>The gemstone ruby is typically what color?</qline>
+        <answers>
+            <answer correct="true">Red</answer>
+            <answer>Blue</answer>
+            <answer>Green</answer>
+            <answer>White</answer>
+        </answers>
+    </question>
+    <question category="earth">
+        <qline>What is the second most common gas found in the air we breathe?</qline>
+        <answers>
+            <answer>Carbon Dioxide</answer>
+            <answer>Nitrogen</answer>
+            <answer>Argon</answer>
+            <answer correct="true">Oxygen</answer>
+        </answers>
+    </question>
+    <question category="space">
+        <qline>What planet is famous for its big red spot on it?</qline>
+        <answers>
+            <answer correct="true">Jupiter</answer>
+            <answer>Uranus</answer>
+            <answer>Venus</answer>
+            <answer>Neptune</answer>
+        </answers>
+    </question>
+    <question category="space">
+        <qline>What is the name of Saturn’s largest moon?</qline>
+        <answers>
+            <answer correct="true">Titan</answer>
+            <answer>Enceladus</answer>
+            <answer>Rhea</answer>
+            <answer>Europa</answer>
+            <answer>Callisto</answer>
+            <answer>Ganymede</answer>
+        </answers>
+    </question>
+    <question category="space">
+        <qline>What is the closest planet to the Sun?</qline>
+        <answers>
+            <answer correct="true">Mercury</answer>
+            <answer>Venus</answer>
+            <answer>Mars</answer>
+            <answer>Saturn</answer>
+        </answers>
+    </question>
+    <question category="math">
+        <qline>What is the next prime number after 7?</qline>
+        <answers>
+            <answer>9</answer>
+            <answer correct="true">11</answer>
+            <answer>12</answer>
+            <answer>15</answer>
+        </answers>
+    </question>
+    <question category="math">
+        <qline>How many sides does a nonagon have?</qline>
+        <answers>
+            <answer>7</answer>
+            <answer>8</answer>
+            <answer correct="true">9</answer>
+            <answer>10</answer>
+        </answers>
+    </question>
+    <question category="math">
+        <qline>In statistics, the middle value of an ordered set of values is called what?</qline>
+        <answers>
+            <answer correct="true">The median</answer>
+            <answer>The mean</answer>
+            <answer>The average</answer>
+        </answers>
+    </question>
+</quiz>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/.classpath
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/.classpath b/ldpath/ldpath-template-linkeddata/.classpath
new file mode 100644
index 0000000..802df60
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/.project
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/.project b/ldpath/ldpath-template-linkeddata/.project
new file mode 100644
index 0000000..ec1c6e9
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ldpath-template-linkeddata</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.core.resources.prefs
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.core.resources.prefs b/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..5eefdcc
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/test/resources=UTF-8

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.jdt.core.prefs
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.jdt.core.prefs b/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..60105c1
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.m2e.core.prefs
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.m2e.core.prefs b/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/pom.xml
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/pom.xml b/ldpath/ldpath-template-linkeddata/pom.xml
new file mode 100644
index 0000000..ee65a2e
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright (c) 2013 Salzburg Research.
+  ~
+  ~  Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>at.newmedialab.ldpath</groupId>
+        <artifactId>ldpath-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../</relativePath>
+    </parent>
+
+    <name>LDPath Templating: Linked Data</name>
+    <artifactId>ldpath-template-linkeddata</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>at.newmedialab.ldpath</groupId>
+            <artifactId>ldpath-backend-linkeddata</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>at.newmedialab.ldpath</groupId>
+            <artifactId>ldpath-template</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+    </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java b/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java
new file mode 100644
index 0000000..c12fa6c
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/src/main/java/at/newmedialab/ldpath/template/LDTemplate.java
@@ -0,0 +1,165 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template;
+
+import at.newmedialab.ldpath.backend.linkeddata.LDMemoryBackend;
+import at.newmedialab.ldpath.backend.linkeddata.LDPersistentBackend;
+import at.newmedialab.ldpath.backend.sesame.SesameRepositoryBackend;
+import at.newmedialab.ldpath.template.engine.TemplateEngine;
+import ch.qos.logback.classic.Level;
+import freemarker.template.TemplateException;
+import org.apache.commons.cli.*;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Value;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class LDTemplate {
+
+
+    private static final Logger log = LoggerFactory.getLogger(LDTemplate.class);
+
+    public static void main(String[] args) {
+        Options options = buildOptions();
+
+        CommandLineParser parser = new PosixParser();
+        try {
+            CommandLine cmd = parser.parse( options, args);
+
+            Level logLevel = Level.WARN;
+
+            if(cmd.hasOption("loglevel")) {
+                String logLevelName = cmd.getOptionValue("loglevel");
+                if("DEBUG".equals(logLevelName.toUpperCase())) {
+                    logLevel = Level.DEBUG;
+                } else if("INFO".equals(logLevelName.toUpperCase())) {
+                    logLevel = Level.INFO;
+                } else if("WARN".equals(logLevelName.toUpperCase())) {
+                    logLevel = Level.WARN;
+                } else if("ERROR".equals(logLevelName.toUpperCase())) {
+                    logLevel = Level.ERROR;
+                } else {
+                    log.error("unsupported log level: {}",logLevelName);
+                }
+            }
+
+            if(logLevel != null) {
+                for(String logname : new String [] {"at","org","net","com"}) {
+
+                    ch.qos.logback.classic.Logger logger =
+                            (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logname);
+                    logger.setLevel(logLevel);
+                }
+            }
+
+            File template = null;
+            if(cmd.hasOption("template")) {
+                template = new File(cmd.getOptionValue("template"));
+            }
+
+
+            SesameRepositoryBackend backend;
+            if(cmd.hasOption("store")) {
+                backend = new LDPersistentBackend(new File(cmd.getOptionValue("store")));
+            } else {
+                backend = new LDMemoryBackend();
+            }
+
+            Resource context = null;
+            if(cmd.hasOption("context")) {
+                context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
+            }
+
+            BufferedWriter out = null;
+            if(cmd.hasOption("out")) {
+                File of = new File(cmd.getOptionValue("out"));
+                if(of.canWrite()) {
+                    out = new BufferedWriter(new FileWriter(of));
+                } else {
+                    log.error("cannot write to output file {}",of);
+                    System.exit(1);
+                }
+            } else {
+                out = new BufferedWriter(new OutputStreamWriter(System.out));
+            }
+
+            if(backend != null && context != null && template != null) {
+                TemplateEngine<Value> engine = new TemplateEngine<Value>(backend);
+
+                engine.setDirectoryForTemplateLoading(template.getParentFile());
+                engine.processFileTemplate(context,template.getName(),out);
+                out.flush();
+            }
+            out.close();
+
+            if(backend instanceof LDPersistentBackend) {
+                ((LDPersistentBackend) backend).shutdown();
+            }
+
+
+        } catch (ParseException e) {
+            System.err.println("invalid arguments");
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp( "LDQuery", options, true );
+        } catch (FileNotFoundException e) {
+            System.err.println("file or program could not be found");
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp("LDQuery", options, true);
+        } catch (IOException e) {
+            System.err.println("could not access file");
+            e.printStackTrace(System.err);
+        } catch (TemplateException e) {
+            System.err.println("error while processing template");
+            e.printStackTrace(System.err);
+        }
+
+
+    }
+
+    private static Options buildOptions() {
+        Options result = new Options();
+
+
+        Option context = OptionBuilder.withArgName("uri").hasArg().withDescription("URI of the context node to start from").create("context");
+        context.setRequired(true);
+        result.addOption(context);
+
+        Option template = OptionBuilder.withArgName("file").hasArg().withDescription("the template file to apply to the context resource").create("template");
+        template.setRequired(true);
+        result.addOption(template);
+
+        Option out = OptionBuilder.withArgName("file").hasArg().withDescription("file where to write the output; if not given, will write to stdout").create("out");
+        out.setRequired(false);
+        result.addOption(out);
+
+        Option loglevel = OptionBuilder.withArgName("level").hasArg().withDescription("set the log level; default is 'warn'").create("loglevel");
+        result.addOption(loglevel);
+
+        Option store = OptionBuilder.withArgName("dir").hasArg().withDescription("cache the retrieved data in this directory").create("store");
+        result.addOption(store);
+
+
+        return result;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template-linkeddata/src/test/resources/city-html.ftl
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template-linkeddata/src/test/resources/city-html.ftl b/ldpath/ldpath-template-linkeddata/src/test/resources/city-html.ftl
new file mode 100644
index 0000000..4911b28
--- /dev/null
+++ b/ldpath/ldpath-template-linkeddata/src/test/resources/city-html.ftl
@@ -0,0 +1,22 @@
+<html>
+    <head>
+        <title><@ldpath path="rdfs:label[@en]"/></title>
+    </head>
+
+    <body>
+        <h1><@ldpath path="rdfs:label[@en]"/></h1>
+
+        <p>
+            <@ldpath path="rdfs:comment[@en]"/>
+        </p>
+
+        <ul>
+            <@ldpath path="fn:sort(rdf:type)">
+                <#if evalLDPath("rdfs:label[@en] :: xsd:string")??>
+                    <li><@ldpath path="rdfs:label[@en] :: xsd:string"/></li>
+                </#if>
+            </...@ldpath>
+        </ul>
+    </body>
+
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/.classpath
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/.classpath b/ldpath/ldpath-template/.classpath
new file mode 100644
index 0000000..595a5bf
--- /dev/null
+++ b/ldpath/ldpath-template/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/.project
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/.project b/ldpath/ldpath-template/.project
new file mode 100644
index 0000000..2014510
--- /dev/null
+++ b/ldpath/ldpath-template/.project
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ldpath-template</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/.settings/org.eclipse.core.resources.prefs
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/.settings/org.eclipse.core.resources.prefs b/ldpath/ldpath-template/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..2b76340
--- /dev/null
+++ b/ldpath/ldpath-template/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/.settings/org.eclipse.jdt.core.prefs
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/.settings/org.eclipse.jdt.core.prefs b/ldpath/ldpath-template/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..60105c1
--- /dev/null
+++ b/ldpath/ldpath-template/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/.settings/org.eclipse.m2e.core.prefs
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/.settings/org.eclipse.m2e.core.prefs b/ldpath/ldpath-template/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/ldpath/ldpath-template/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/.settings/org.eclipse.pde.core.prefs
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/.settings/org.eclipse.pde.core.prefs b/ldpath/ldpath-template/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 0000000..ba582c2
--- /dev/null
+++ b/ldpath/ldpath-template/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,2 @@
+BUNDLE_ROOT_PATH=target/classes
+eclipse.preferences.version=1

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/pom.xml
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/pom.xml b/ldpath/ldpath-template/pom.xml
new file mode 100644
index 0000000..3cb6a52
--- /dev/null
+++ b/ldpath/ldpath-template/pom.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright (c) 2013 Salzburg Research.
+  ~
+  ~  Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>at.newmedialab.ldpath</groupId>
+        <artifactId>ldpath-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../</relativePath>
+    </parent>
+
+    <name>LDPath Templating: Core</name>
+    <artifactId>ldpath-template</artifactId>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+
+
+        <dependency>
+            <groupId>at.newmedialab.ldpath</groupId>
+            <artifactId>ldpath-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>at.newmedialab.ldpath</groupId>
+            <artifactId>ldpath-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+        </dependency>
+
+
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>LDPath Templating</Bundle-Name>
+                        <!-- Enable this for including your enhancement chain configuration -->
+                        <!-- <Install-Path>config</Install-Path> -->
+                        <Export-Package>
+                            at.newmedialab.ldpath.template;version=${project.version},
+                            at.newmedialab.ldpath.template.engine;version=${project.version},
+                            at.newmedialab.ldpath.template.model;version=${project.version},
+                            at.newmedialab.ldpath.template.util;version=${project.version}
+                        </Export-Package>
+                        <!--
+                        <_exportcontents>freemarker.*;version="2.3.19"</_exportcontents>
+                        <Embed-Dependency>freemarker;scope=compile</Embed-Dependency>
+                        <Import-Package>
+                            !com.sun.org.apache*, javax.el*;resolution:=optional;version="[1,2)",
+                            javax.servlet*;resolution:=optional;version="[2.5,3)",
+                            javax.servlet.jsp*;resolution:=optional;version="[2.1,3)",
+                            javax.swing*;resolution:=optional,
+                            org.apache.log;resolution:=optional;version="[1.0.1,1.0.1]",
+                            org.apache.log4j;resolution:=optional;version="[1.2,2)",
+                            org.apache.tools.ant*;resolution:=optional;version="[1.7,2)",
+                            org.apache.xml.utils;resolution:=optional;version="[2.7,3)",
+                            org.apache.xpath*;resolution:=optional;version="[2.7,3)",
+                            org.dom4j*;resolution:=optional;version="[1.6.1,2)",
+                            org.jaxen*;resolution:=optional;version="[1.1.1,2)",
+                            org.jdom*;resolution:=optional;version="[1,2)",
+                            org.mozilla.javascript;resolution:=optional,
+                            org.python*;resolution:=optional;version="[2.2.1,2.3)",
+                            org.zeroturnaround.javarebel;resolution:=optional,
+                            org.w3c.dom.traversal;resolution:=optional,
+                            *
+                        </Import-Package>
+                        -->
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-scr-scrdescriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                        <configuration>
+                            <properties>
+                                <service.vendor>Salzburg Research</service.vendor>
+                            </properties>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java
new file mode 100644
index 0000000..fea20e6
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathDirective.java
@@ -0,0 +1,200 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.engine;
+
+import at.newmedialab.ldpath.LDPath;
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.exception.LDPathParseException;
+import at.newmedialab.ldpath.model.Constants;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateNodeModel;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateStackModel;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateWrapperModel;
+import at.newmedialab.ldpath.template.model.transformers.*;
+import at.newmedialab.ldpath.template.util.FormatUtil;
+import freemarker.core.Environment;
+import freemarker.template.*;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A directive for inserting values retrieved with LDPath. It can be used in several forms:
+ * <p/>
+ * <strong>Value Insertion (without body):</strong><br/>
+ * Allows inserting the value of a path expression. The path expression should specify an XML schema type for the
+ * type conversion. If no type is given, string conversion is assumed. If the expression would return several values,
+ * only the first result is taken.
+ * <p/>
+ * <code>
+ * &lt;@ldpath path="... :: xsd:type">
+ * </code>
+ * <p/>
+ * <strong>Value Iteration (with body):</strong>
+ * Allows iterating over result nodes of a path expression. Further path expressions can be used to select the
+ * values of each result node.
+ * <p/>
+ * <code>
+ * &lt;@ldpath path="..."><br/>
+ *    &nbsp;...<br/>
+ *    &nbsp;&lt;@ldpath path="..."><br/>
+ *    &nbsp;...<br/>
+ * &lt;/@ldpath>
+ * </code>
+ * <p/>
+ * If a loop variable is given, it will be bound to the context node. The context node is also implicitly available
+ * as the variable "context".
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class LDPathDirective<Node> implements TemplateDirectiveModel {
+
+
+    private LDPath<Node>     ldpath;
+    private RDFBackend<Node> backend;
+
+    public LDPathDirective(RDFBackend<Node> backend) {
+        this.ldpath  = new LDPath<Node>(backend);
+        this.backend = backend;
+
+        // register custom freemarker transformers for the parser so we get the results immediately in the freemarker model
+        ldpath.registerTransformer(Constants.NS_XSD + "string", new TemplateScalarTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "decimal", new TemplateLongTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "integer", new TemplateIntegerTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "long", new TemplateLongTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "short", new TemplateIntegerTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "double", new TemplateDoubleTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "float", new TemplateFloatTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "dateTime", new TemplateDateTransformer<Node>(TemplateDateModel.DATETIME));
+        ldpath.registerTransformer(Constants.NS_XSD + "date", new TemplateDateTransformer<Node>(TemplateDateModel.DATE));
+        ldpath.registerTransformer(Constants.NS_XSD + "time", new TemplateDateTransformer<Node>(TemplateDateModel.TIME));
+        ldpath.registerTransformer(Constants.NS_XSD + "boolean", new TemplateBooleanTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "anyURI", new TemplateScalarTransformer<Node>());
+
+    }
+
+    /**
+     * Executes this user-defined directive; called by FreeMarker when the user-defined
+     * directive is called in the template.
+     *
+     * @param env      the current processing environment. Note that you can access
+     *                 the output {@link java.io.Writer Writer} by {@link freemarker.core.Environment#getOut()}.
+     * @param params   the parameters (if any) passed to the directive as a
+     *                 map of key/value pairs where the keys are {@link String}-s and the
+     *                 values are {@link freemarker.template.TemplateModel} instances. This is never
+     *                 <code>null</code>. If you need to convert the template models to POJOs,
+     *                 you can use the utility methods in the {@link freemarker.template.utility.DeepUnwrap} class.
+     * @param loopVars an array that corresponds to the "loop variables", in
+     *                 the order as they appear in the directive call. ("Loop variables" are out-parameters
+     *                 that are available to the nested body of the directive; see in the Manual.)
+     *                 You set the loop variables by writing this array. The length of the array gives the
+     *                 number of loop-variables that the caller has specified.
+     *                 Never <code>null</code>, but can be a zero-length array.
+     * @param body     an object that can be used to render the nested content (body) of
+     *                 the directive call. If the directive call has no nested content (i.e., it is like
+     *                 [@myDirective /] or [@myDirective][/@myDirective]), then this will be
+     *                 <code>null</code>.
+     * @throws freemarker.template.TemplateException
+     *
+     * @throws java.io.IOException
+     */
+    @Override
+    public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
+        TemplateStackModel contextStack = (TemplateStackModel)env.getVariable("context");
+        if(contextStack == null || contextStack.empty()) {
+            throw new TemplateModelException("error; no context node available");
+        }
+        TemplateNodeModel<Node> context = (TemplateNodeModel<Node>)contextStack.peek();
+
+        SimpleScalar pathScalar = (SimpleScalar)params.get("path");
+        if(pathScalar == null) {
+            throw new TemplateException("the directive has been called without a path parameter",env);
+        }
+        String path = pathScalar.getAsString();
+
+        TemplateWrapperModel<Map<String,String>> namespacesWrapped = (TemplateWrapperModel<Map<String,String>>)env.getGlobalVariable("namespaces");
+
+        Map<String,String> namespaces;
+        if(namespacesWrapped == null) {
+            namespaces = new HashMap<String, String>();
+            namespacesWrapped = new TemplateWrapperModel<Map<String, String>>(new HashMap<String, String>());
+            env.setGlobalVariable("namespaces",namespacesWrapped);
+        } else {
+            namespaces = namespacesWrapped.getAdaptedObject(Map.class);
+        }
+
+
+        if(body == null) { // value insertion
+            if(!path.contains("::")) {
+                path = path + ":: xsd:string";
+            }
+            try {
+                Collection results = ldpath.pathTransform(context.getNode(),path,namespaces);
+
+                if(results.size() > 0) {
+                    Object result = results.iterator().next();
+
+                    if(result instanceof TemplateNumberModel) {
+                        env.getOut().write(FormatUtil.formatNumber( ((TemplateNumberModel)result).getAsNumber() ));
+                    } else if(result instanceof TemplateDateModel) {
+                        switch (((TemplateDateModel)result).getDateType()) {
+                            case TemplateDateModel.DATE:
+                                env.getOut().write(FormatUtil.formatDate(((TemplateDateModel)result).getAsDate()));
+                                break;
+                            case TemplateDateModel.TIME:
+                                env.getOut().write(FormatUtil.formatTime(((TemplateDateModel)result).getAsDate()));
+                                break;
+                            case TemplateDateModel.DATETIME:
+                                env.getOut().write(FormatUtil.formatDateTime(((TemplateDateModel)result).getAsDate()));
+                                break;
+                            default:
+                                env.getOut().write(FormatUtil.formatDateTime(((TemplateDateModel)result).getAsDate()));
+                        }
+                    } else if(result instanceof TemplateScalarModel) {
+                        env.getOut().write( ((TemplateScalarModel)result).getAsString() );
+                    } else if(result instanceof TemplateBooleanModel) {
+                        env.getOut().write( Boolean.toString(((TemplateBooleanModel)result).getAsBoolean()) );
+                    }
+
+                } // else write nothing
+
+
+            } catch (LDPathParseException e) {
+                throw new TemplateException("invalid path for ldpath directive: "+path,e,env);
+            }
+
+        } else {
+            try {
+                for(Node node : ldpath.pathQuery(context.getNode(),path,namespaces)) {
+                    contextStack.push(new TemplateNodeModel<Node>(node, backend));
+
+                    if(loopVars.length > 0) {
+                        loopVars[0] = new TemplateNodeModel<Node>(node,backend);
+                    }
+
+                    body.render(env.getOut());
+
+                    contextStack.pop();
+                }
+            } catch(LDPathParseException ex) {
+                throw new TemplateException("invalid path for ldpath directive: "+path,ex,env);
+            }
+
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java
new file mode 100644
index 0000000..6fba273
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/LDPathMethod.java
@@ -0,0 +1,131 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.engine;
+
+import at.newmedialab.ldpath.LDPath;
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.exception.LDPathParseException;
+import at.newmedialab.ldpath.model.Constants;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateNodeModel;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateStackModel;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateWrapperModel;
+import at.newmedialab.ldpath.template.model.transformers.*;
+import freemarker.core.Environment;
+import freemarker.template.TemplateDateModel;
+import freemarker.template.TemplateMethodModel;
+import freemarker.template.TemplateModelException;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class LDPathMethod<Node> implements TemplateMethodModel {
+
+
+    private LDPath<Node> ldpath;
+    private RDFBackend<Node> backend;
+
+    public LDPathMethod(RDFBackend<Node> backend) {
+        this.ldpath  = new LDPath<Node>(backend);
+        this.backend = backend;
+
+        // register custom freemarker transformers for the parser so we get the results immediately in the freemarker model
+        ldpath.registerTransformer(Constants.NS_XSD + "string", new TemplateScalarTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "decimal", new TemplateLongTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "integer", new TemplateIntegerTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "long", new TemplateLongTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "short", new TemplateIntegerTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "double", new TemplateDoubleTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "float", new TemplateFloatTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "dateTime", new TemplateDateTransformer<Node>(TemplateDateModel.DATETIME));
+        ldpath.registerTransformer(Constants.NS_XSD + "date", new TemplateDateTransformer<Node>(TemplateDateModel.DATE));
+        ldpath.registerTransformer(Constants.NS_XSD + "time", new TemplateDateTransformer<Node>(TemplateDateModel.TIME));
+        ldpath.registerTransformer(Constants.NS_XSD + "boolean", new TemplateBooleanTransformer<Node>());
+        ldpath.registerTransformer(Constants.NS_XSD + "anyURI", new TemplateScalarTransformer<Node>());
+
+    }
+
+
+    /**
+     * Executes a method call. All arguments passed to the method call are
+     * coerced to strings before being passed, if the FreeMarker rules allow
+     * the coercion. If some of the passed arguments can not be coerced to a
+     * string, an exception will be raised in the engine and the method will
+     * not be called. If your method would like to act on actual data model
+     * objects instead of on their string representations, implement the
+     * {@link freemarker.template.TemplateMethodModelEx} instead.
+     *
+     * @param arguments a <tt>List</tt> of <tt>String</tt> objects
+     *                  containing the values of the arguments passed to the method.
+     * @return the return value of the method, or null. If the returned value
+     *         does not implement {@link freemarker.template.TemplateModel}, it will be automatically
+     *         wrapped using the {@link freemarker.core.Environment#getObjectWrapper() environment
+     *         object wrapper}.
+     */
+    @Override
+    public Object exec(List arguments) throws TemplateModelException {
+        Environment env = Environment.getCurrentEnvironment();
+
+
+        TemplateStackModel contextStack = (TemplateStackModel)env.getVariable("context");
+        if(contextStack == null || contextStack.empty()) {
+            throw new TemplateModelException("error; no context node available");
+        }
+        TemplateNodeModel<Node> context = (TemplateNodeModel<Node>)contextStack.peek();
+
+        String path;
+        if(arguments.size() != 1) {
+            throw new TemplateModelException("the directive has been called without a path parameter");
+        } else {
+            path = (String)arguments.get(0);
+            if(!path.contains("::")) {
+                path = path + " :: xsd:string";
+            }
+        }
+
+        TemplateWrapperModel<Map<String,String>> namespacesWrapped = (TemplateWrapperModel<Map<String,String>>)env.getGlobalVariable("namespaces");
+
+        Map<String,String> namespaces;
+        if(namespacesWrapped == null) {
+            namespaces = new HashMap<String, String>();
+            namespacesWrapped = new TemplateWrapperModel<Map<String, String>>(new HashMap<String, String>());
+            env.setGlobalVariable("namespaces",namespacesWrapped);
+        } else {
+            namespaces = namespacesWrapped.getAdaptedObject(Map.class);
+        }
+
+        if(arguments.size() != 1) {
+            throw new TemplateModelException("wrong number of arguments for method call");
+        }
+
+        try {
+            Collection result = ldpath.pathTransform(context.getNode(),path,namespaces);
+            if(result.size() > 0) {
+                return result;
+            } else {
+                return null;
+            }
+        } catch (LDPathParseException e) {
+            throw new TemplateModelException("could not parse path expression '"+path+"'",e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java
new file mode 100644
index 0000000..f17b09a
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/NamespaceDirective.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.engine;
+
+import at.newmedialab.ldpath.template.model.freemarker.TemplateWrapperModel;
+import freemarker.core.Environment;
+import freemarker.template.TemplateDirectiveBody;
+import freemarker.template.TemplateDirectiveModel;
+import freemarker.template.TemplateException;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateScalarModel;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class NamespaceDirective implements TemplateDirectiveModel {
+
+
+    public NamespaceDirective() {
+    }
+
+    /**
+     * Executes this user-defined directive; called by FreeMarker when the user-defined
+     * directive is called in the template.
+     *
+     * @param env      the current processing environment. Note that you can access
+     *                 the output {@link java.io.Writer Writer} by {@link freemarker.core.Environment#getOut()}.
+     * @param params   the parameters (if any) passed to the directive as a
+     *                 map of key/value pairs where the keys are {@link String}-s and the
+     *                 values are {@link freemarker.template.TemplateModel} instances. This is never
+     *                 <code>null</code>. If you need to convert the template models to POJOs,
+     *                 you can use the utility methods in the {@link freemarker.template.utility.DeepUnwrap} class.
+     * @param loopVars an array that corresponds to the "loop variables", in
+     *                 the order as they appear in the directive call. ("Loop variables" are out-parameters
+     *                 that are available to the nested body of the directive; see in the Manual.)
+     *                 You set the loop variables by writing this array. The length of the array gives the
+     *                 number of loop-variables that the caller has specified.
+     *                 Never <code>null</code>, but can be a zero-length array.
+     * @param body     an object that can be used to render the nested content (body) of
+     *                 the directive call. If the directive call has no nested content (i.e., it is like
+     *                 [@myDirective /] or [@myDirective][/@myDirective]), then this will be
+     *                 <code>null</code>.
+     * @throws freemarker.template.TemplateException
+     *
+     * @throws java.io.IOException
+     */
+    @Override
+    public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
+        TemplateWrapperModel<Map<String,String>> namespacesWrapped = (TemplateWrapperModel<Map<String,String>>)env.getGlobalVariable("namespaces");
+
+        Map<String,String> namespaces;
+        if(namespacesWrapped == null) {
+            namespaces = new HashMap<String, String>();
+            namespacesWrapped = new TemplateWrapperModel<Map<String, String>>(namespaces);
+            env.setGlobalVariable("namespaces",namespacesWrapped);
+        } else {
+            namespaces = namespacesWrapped.getAdaptedObject(Map.class);
+        }
+
+
+        Iterator paramIter = params.entrySet().iterator();
+        while (paramIter.hasNext()) {
+            Map.Entry ent = (Map.Entry) paramIter.next();
+
+            String paramName = (String) ent.getKey();
+            TemplateModel paramValue = (TemplateModel) ent.getValue();
+
+            if(paramValue instanceof TemplateScalarModel) {
+                String uri = ((TemplateScalarModel)paramValue).getAsString();
+
+                try {
+                    URI test = new URI(uri);
+                    namespaces.put(paramName,test.toString());
+                } catch (URISyntaxException e) {
+                    throw new TemplateModelException("invalid namespace URI '"+uri+"'",e);
+                }
+            }
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java
new file mode 100644
index 0000000..6de4078
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/engine/TemplateEngine.java
@@ -0,0 +1,131 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.engine;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateNodeModel;
+import at.newmedialab.ldpath.template.model.freemarker.TemplateStackModel;
+import freemarker.cache.TemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.DefaultObjectWrapper;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateEngine<Node> {
+
+    private Configuration freemarker;
+
+    private RDFBackend<Node> backend;
+
+    public TemplateEngine(RDFBackend<Node> backend) {
+
+        this.backend = backend;
+
+        freemarker = new Configuration();
+        freemarker.setObjectWrapper(new DefaultObjectWrapper());
+
+
+    }
+
+
+    /**
+     * Allow setting a different template loader. Custom template loaders can be implemented in addition to
+     * those provided by FreeMarker.
+     *
+     * @param loader
+     */
+    public void setTemplateLoader(TemplateLoader loader) {
+        freemarker.setTemplateLoader(loader);
+    }
+
+
+    public void setDirectoryForTemplateLoading(File dir) throws IOException {
+        freemarker.setDirectoryForTemplateLoading(dir);
+    }
+
+    public void setServletContextForTemplateLoading(Object sctxt, String path) {
+        freemarker.setServletContextForTemplateLoading(sctxt, path);
+    }
+
+    public void setClassForTemplateLoading(Class clazz, String pathPrefix) {
+        freemarker.setClassForTemplateLoading(clazz, pathPrefix);
+    }
+
+
+    /**
+     * Process the template with the given name forn the given context node and write the result to the given
+     * output writer. The way the template is retrieved depends on the template loader, which can be set using the
+     * setTemplateLoader() method.
+     *
+     * @param context the  initial context node to apply this template to
+     * @param templateName the name of the template
+     * @param out          where to write the results
+     * @throws IOException
+     * @throws TemplateException
+     */
+    public void processFileTemplate(Node context, String templateName, Writer out) throws IOException, TemplateException {
+        processTemplate(context,freemarker.getTemplate(templateName),null,out);
+    }
+
+    /**
+     * Process the template with the given name forn the given context node and write the result to the given
+     * output writer. The initial environment is passed over to the invocation of the template. The way the template
+     * is retrieved depends on the template loader, which can be set using the setTemplateLoader() method.
+     *
+     * @param context the  initial context node to apply this template to
+     * @param templateName the name of the template
+     * @param initialEnv   an initial root environment for processing the template
+     * @param out          where to write the results
+     * @throws IOException
+     * @throws TemplateException
+     */
+    public void processFileTemplate(Node context, String templateName, Map initialEnv,  Writer out) throws IOException, TemplateException {
+        processTemplate(context,freemarker.getTemplate(templateName),initialEnv,out);
+    }
+
+
+    private void processTemplate(Node context, Template template, Map initialEnv, Writer out) throws IOException, TemplateException {
+        Map root = new HashMap();
+
+        if(initialEnv != null) {
+            for(Map.Entry entry : (Set<Map.Entry>) initialEnv.entrySet()) {
+                root.put(entry.getKey(), entry.getValue());
+            }
+        }
+
+        root.put("namespace", new NamespaceDirective());
+        root.put("evalLDPath",new LDPathMethod(backend));
+        root.put("ldpath",new LDPathDirective(backend));
+
+        TemplateStackModel contexts = new TemplateStackModel();
+        contexts.push(new TemplateNodeModel(context,backend));
+        root.put("context",contexts);
+
+        template.process(root,out);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java
new file mode 100644
index 0000000..47ea772
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateNodeModel.java
@@ -0,0 +1,108 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.freemarker;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import freemarker.template.*;
+
+/**
+ * A custom freemarker model to represent RDF nodes (implementation independent, generic)
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateNodeModel<Node> implements TemplateModel, TemplateHashModel, AdapterTemplateModel {
+
+    private Node node;
+    private RDFBackend<Node> backend;
+
+    public TemplateNodeModel(Node node, RDFBackend<Node> backend) {
+        this.node    = node;
+        this.backend = backend;
+    }
+
+    public Node getNode() {
+        return node;
+    }
+
+    /**
+     * Gets a <tt>TemplateModel</tt> from the hash.
+     *
+     * @param key the name by which the <tt>TemplateModel</tt>
+     *            is identified in the template.
+     * @return the <tt>TemplateModel</tt> referred to by the key,
+     *         or null if not found.
+     */
+    @Override
+    public TemplateModel get(String key) throws TemplateModelException {
+        if( ("uri".equals(key) && backend.isURI(node)) || ("content".equals(key) && backend.isLiteral(node))) {
+            return new TemplateScalarModel() {
+                @Override
+                public String getAsString() throws TemplateModelException {
+                    return backend.stringValue(node);
+                }
+            };
+        } else if("language".equals(key) && backend.isLiteral(node)) {
+            return new TemplateScalarModel() {
+                @Override
+                public String getAsString() throws TemplateModelException {
+                    return backend.getLiteralLanguage(node).getLanguage();
+                }
+            };
+        } else if("type".equals(key) && backend.isLiteral(node)) {
+            return new TemplateScalarModel() {
+                @Override
+                public String getAsString() throws TemplateModelException {
+                    return backend.getLiteralType(node).toString();
+                }
+            };
+        } else if("id".equals(key) && backend.isBlank(node)) {
+            return new TemplateScalarModel() {
+                @Override
+                public String getAsString() throws TemplateModelException {
+                    return backend.stringValue(node);
+                }
+            };
+        }
+        return null;
+    }
+
+    @Override
+    public boolean isEmpty() throws TemplateModelException {
+        return false;
+    }
+
+    /**
+     * Retrieves the underlying object, or some other object semantically
+     * equivalent to its value narrowed by the class hint.
+     *
+     * @param hint the desired class of the returned value. An implementation
+     *             should make reasonable effort to retrieve an object of the requested
+     *             class, but if that is impossible, it must at least return the underlying
+     *             object as-is. As a minimal requirement, an implementation must always
+     *             return the exact underlying object when
+     *             <tt>hint.isInstance(underlyingObject) == true</tt> holds. When called
+     *             with <tt>java.lang.Object.class</tt>, it should return a generic Java
+     *             object (i.e. if the model is wrapping a scripting lanugage object that is
+     *             further wrapping a Java object, the deepest underlying Java object should
+     *             be returned).
+     * @return the underlying object, or its value accommodated for the hint
+     *         class.
+     */
+    @Override
+    public Object getAdaptedObject(Class hint) {
+        return node;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java
new file mode 100644
index 0000000..3820a55
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateStackModel.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.freemarker;
+
+import freemarker.template.TemplateModel;
+
+import java.util.Stack;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateStackModel implements TemplateModel {
+
+    private Stack<TemplateModel> stack;
+
+    public TemplateStackModel() {
+        stack = new Stack<TemplateModel>();
+    }
+
+
+    public TemplateModel push(TemplateModel item) {
+        return stack.push(item);
+    }
+
+    public TemplateModel pop() {
+        return stack.pop();
+    }
+
+    public TemplateModel peek() {
+        return stack.peek();
+    }
+
+    public boolean empty() {
+        return stack.empty();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java
new file mode 100644
index 0000000..d8006d1
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/freemarker/TemplateWrapperModel.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.freemarker;
+
+import freemarker.template.AdapterTemplateModel;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateWrapperModel<T> implements AdapterTemplateModel {
+
+    private T object;
+
+    public TemplateWrapperModel(T object) {
+        this.object = object;
+    }
+
+    /**
+     * Retrieves the underlying object, or some other object semantically
+     * equivalent to its value narrowed by the class hint.
+     *
+     * @param hint the desired class of the returned value. An implementation
+     *             should make reasonable effort to retrieve an object of the requested
+     *             class, but if that is impossible, it must at least return the underlying
+     *             object as-is. As a minimal requirement, an implementation must always
+     *             return the exact underlying object when
+     *             <tt>hint.isInstance(underlyingObject) == true</tt> holds. When called
+     *             with <tt>java.lang.Object.class</tt>, it should return a generic Java
+     *             object (i.e. if the model is wrapping a scripting lanugage object that is
+     *             further wrapping a Java object, the deepest underlying Java object should
+     *             be returned).
+     * @return the underlying object, or its value accommodated for the hint
+     *         class.
+     */
+    @Override
+    public T getAdaptedObject(Class hint) {
+        return object;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java
new file mode 100644
index 0000000..8bd5a88
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateBooleanTransformer.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.transformers;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.api.transformers.NodeTransformer;
+import at.newmedialab.ldpath.model.transformers.BooleanTransformer;
+import freemarker.template.TemplateBooleanModel;
+import freemarker.template.TemplateModelException;
+
+/**
+ * Transform a node into the freemarker boolean type (TemplateBooleanModel).
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateBooleanTransformer<Node> implements NodeTransformer<TemplateBooleanModel,Node> {
+
+    private BooleanTransformer<Node> delegate;
+
+    public TemplateBooleanTransformer() {
+        delegate = new BooleanTransformer<Node>();
+    }
+
+    /**
+     * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+     * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+     * carrying out the transformation.
+     *
+     * @param node
+     * @return
+     */
+    @Override
+    public TemplateBooleanModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
+        return new TemplateBooleanModel() {
+            @Override
+            public boolean getAsBoolean() throws TemplateModelException {
+                return delegate.transform(nodeRDFBackend,node);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java
new file mode 100644
index 0000000..278f721
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDateTransformer.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.transformers;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.api.transformers.NodeTransformer;
+import at.newmedialab.ldpath.model.transformers.DateTimeTransformer;
+import freemarker.template.TemplateDateModel;
+import freemarker.template.TemplateModelException;
+
+import java.util.Date;
+
+/**
+ * Transform a node into the freemarker date type ({@link freemarker.template.TemplateDateModel}).
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateDateTransformer<Node> implements NodeTransformer<TemplateDateModel,Node> {
+
+    private DateTimeTransformer<Node> delegate;
+
+    private int type = TemplateDateModel.UNKNOWN;
+
+    public TemplateDateTransformer() {
+        delegate = new DateTimeTransformer<Node>();
+    }
+
+    public TemplateDateTransformer(int type) {
+        this.type = type;
+    }
+
+    /**
+     * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+     * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+     * carrying out the transformation.
+     *
+     * @param node
+     * @return
+     */
+    @Override
+    public TemplateDateModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
+        return new TemplateDateModel() {
+            @Override
+            public Date getAsDate() throws TemplateModelException {
+                return delegate.transform(nodeRDFBackend, node);
+            }
+
+            @Override
+            public int getDateType() {
+                return type;
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDoubleTransformer.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDoubleTransformer.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDoubleTransformer.java
new file mode 100644
index 0000000..209ac70
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateDoubleTransformer.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.transformers;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.api.transformers.NodeTransformer;
+import at.newmedialab.ldpath.model.transformers.DoubleTransformer;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateNumberModel;
+
+/**
+ * Transform a node into the freemarker double type (TemplateDoubleModel).
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateDoubleTransformer<Node> implements NodeTransformer<TemplateNumberModel,Node> {
+
+    private DoubleTransformer<Node> delegate;
+
+    public TemplateDoubleTransformer() {
+        delegate = new DoubleTransformer<Node>();
+    }
+
+    /**
+     * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+     * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+     * carrying out the transformation.
+     *
+     * @param node
+     * @return
+     */
+    @Override
+    public TemplateNumberModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
+        return new TemplateNumberModel() {
+            @Override
+            public Number getAsNumber() throws TemplateModelException {
+                return delegate.transform(nodeRDFBackend,node);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateFloatTransformer.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateFloatTransformer.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateFloatTransformer.java
new file mode 100644
index 0000000..f9fda18
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateFloatTransformer.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.transformers;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.api.transformers.NodeTransformer;
+import at.newmedialab.ldpath.model.transformers.FloatTransformer;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateNumberModel;
+
+/**
+ * Transform a node into the freemarker float type (TemplateFloatModel).
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateFloatTransformer<Node> implements NodeTransformer<TemplateNumberModel,Node> {
+
+    private FloatTransformer<Node> delegate;
+
+    public TemplateFloatTransformer() {
+        delegate = new FloatTransformer<Node>();
+    }
+
+    /**
+     * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+     * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+     * carrying out the transformation.
+     *
+     * @param node
+     * @return
+     */
+    @Override
+    public TemplateNumberModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
+        return new TemplateNumberModel() {
+            @Override
+            public Number getAsNumber() throws TemplateModelException {
+                return delegate.transform(nodeRDFBackend,node);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateIntegerTransformer.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateIntegerTransformer.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateIntegerTransformer.java
new file mode 100644
index 0000000..840a13d
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateIntegerTransformer.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.transformers;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.api.transformers.NodeTransformer;
+import at.newmedialab.ldpath.model.transformers.IntTransformer;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateNumberModel;
+
+/**
+ * Transform a node into the freemarker integer type (TemplateNumberModel).
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateIntegerTransformer<Node> implements NodeTransformer<TemplateNumberModel,Node> {
+
+    private IntTransformer<Node> delegate;
+
+    public TemplateIntegerTransformer() {
+        delegate = new IntTransformer<Node>();
+    }
+
+    /**
+     * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+     * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+     * carrying out the transformation.
+     *
+     * @param node
+     * @return
+     */
+    @Override
+    public TemplateNumberModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
+        return new TemplateNumberModel() {
+            @Override
+            public Number getAsNumber() throws TemplateModelException {
+                return delegate.transform(nodeRDFBackend, node);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateLongTransformer.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateLongTransformer.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateLongTransformer.java
new file mode 100644
index 0000000..3fc67b4
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateLongTransformer.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.transformers;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.api.transformers.NodeTransformer;
+import at.newmedialab.ldpath.model.transformers.LongTransformer;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateNumberModel;
+
+/**
+ * Transform a node into the freemarker long type (TemplateNumberModel).
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateLongTransformer<Node> implements NodeTransformer<TemplateNumberModel,Node> {
+
+    private LongTransformer delegate;
+
+    public TemplateLongTransformer() {
+        delegate = new LongTransformer();
+    }
+
+    /**
+     * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+     * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+     * carrying out the transformation.
+     *
+     * @param node
+     * @return
+     */
+    @Override
+    public TemplateNumberModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
+        return new TemplateNumberModel() {
+            @Override
+            public Number getAsNumber() throws TemplateModelException {
+                return delegate.transform(nodeRDFBackend, node);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateScalarTransformer.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateScalarTransformer.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateScalarTransformer.java
new file mode 100644
index 0000000..82d6160
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/model/transformers/TemplateScalarTransformer.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.model.transformers;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.api.transformers.NodeTransformer;
+import at.newmedialab.ldpath.model.transformers.StringTransformer;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateScalarModel;
+
+/**
+ * Transform a node into the freemarker string (scalar) type (TemplateScalarModel).
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TemplateScalarTransformer<Node> implements NodeTransformer<TemplateScalarModel,Node> {
+
+    private StringTransformer<Node> delegate;
+
+
+    public TemplateScalarTransformer() {
+        delegate = new StringTransformer<Node>();
+    }
+
+    /**
+     * Transform the KiWiNode node into the datatype T. In case the node cannot be transformed to
+     * the respective datatype, throws an IllegalArgumentException that needs to be caught by the class
+     * carrying out the transformation.
+     *
+     * @param node
+     * @return
+     */
+    @Override
+    public TemplateScalarModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node) throws IllegalArgumentException {
+        return new TemplateScalarModel() {
+            @Override
+            public String getAsString() throws TemplateModelException {
+                return delegate.transform(nodeRDFBackend,node);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/32a909f7/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/util/FormatUtil.java
----------------------------------------------------------------------
diff --git a/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/util/FormatUtil.java b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/util/FormatUtil.java
new file mode 100644
index 0000000..a3332f9
--- /dev/null
+++ b/ldpath/ldpath-template/src/main/java/at/newmedialab/ldpath/template/util/FormatUtil.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.newmedialab.ldpath.template.util;
+
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * A utility class for formatting Java values when writing out the templating results. The methods are implemented
+ * to copy the formatting behaviour of FreeMarker
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class FormatUtil {
+
+
+    public static String formatNumber(Number number) {
+        NumberFormat format = NumberFormat.getNumberInstance(Locale.getDefault());
+        return format.format(number);
+    }
+
+
+    public static String formatDate(Date date) {
+        DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.getDefault());
+        return format.format(date);
+    }
+
+    public static String formatTime(Date date) {
+        DateFormat format = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.getDefault());
+        return format.format(date);
+    }
+
+    public static String formatDateTime(Date date) {
+        DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.getDefault());
+        return format.format(date);
+    }
+
+}