This project has retired. For details please refer to its Attic page.
Apache Marmotta - LDPath - Template

LDPath Template

LDPath implements an extension of the FreeMarker template engine that allows constructing templates with LDPath statements for inserting and iterating over values.

Template example

<@namespace rdfs="" />
        <title><@ldpath path="rdfs:label[@en]"/></title>

        <h1><@ldpath path="rdfs:label[@en]"/></h1>

            <@ldpath path="rdfs:comment[@en]"/>

            <@ldpath path="fn:sort(rdf:type)">
                <#if evalLDPath("rdfs:label[@en] :: xsd:string")??>
                    <li><@ldpath path="rdfs:label[@en] :: xsd:string"/></li>



To use this templating mechanism you would need to include the following artifact in your Maven build file:


This is the basic Java code for rendering LDPath templates:

final RepositoryConnection conn = ...getConnection();
try {
    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 {