Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Twinkql Logl

Build Status

This service implementation has been archived.

What is Twinkql?

Twinkql is a SPARQL to Object Mapping Framework that allows users to bind named SPARQL queries to ResultMaps, which in turn may be bound to beans.
Twinkql has a few simple goals

  1. Many times accessing a SPARQL endpoint is only one layer of a complex application. An application may use data from a SPARQL endpoint to power a REST or SOAP service, to validate parts of the system, or any number of different applications. In this case, we need to go from SPARQL query to application-specific beans as quickly as possible, and with the least amount of code.

  2. SPARQL in your code is hard to maintain. In Java, for example, complex SPARQL in in Java files is represented as large String concatenations. This limits the readability of your code. Moving the SPARQL queries to XML files let you have a clean separation between application logic and SPARQL queries.

  3. Accessing a SPARQL endpoint should be no harder than a SQL datasource. In fact, your application should only be concerned with the query you want to execute and what parameters you need put in that query.

A Simple Select

For example, say I want to find all of the labels and comments from all the owl Ontologies. In Twinkql, I can specify that query in XML, keeping it separate from the rest of my program code.

<select id="myTestQuery">
SELECT ?label ?note
    WHERE {
        ?s a <>;
            rdfs:label ?label ;
            rdfs:comment ?comment .

Passing in a variable

What if there is a query parameter in my search? Twinkql can handle that with Parameter Substitution.

<select id="myTestQuery">
SELECT ?label ?note
    WHERE {
        ?s a <>;
            rdfs:label ?label ;
            rdfs:comment ?comment ; 
            <http://my/ns#myproperty> #{myQueryParam}

In this case, when I execute my query, I simply pass in a Map with a key of 'myQueryParam' - and whatever value is associated with that key will be injected into my query.

Binding Results to a Bean

In many applications, the SPARQL query is just part of the architecture. Results from a SPARQL query may need to be manipulated further, passed into a messaging queue, processed into a different format, etc. Twinql allows you to bind beans to SPARQL query results via 'ResultMaps'. Result maps simply take a variable from the SPARQL query (the 'var' attribute) and map it to a property on your result bean (the 'beanProperty' attribute).

<resultMap id="myTestResultMap" 
    <rowMap var="label" varType="literalValue" beanProperty="name"/>
    <rowMap var="comment" varType="literalValue" beanProperty="node"/>

In this example, a bean of class 'com.sample.twinkql.Bean' will be instantiated, and for each row of the SPARQL result set returned, the variables will be bound. The user will be returned a Collectin of the resulting beans.


[Apache 2.0 license](">Apache 2.0 license)


Twinkql has been heavily inspired by the MyBatis Project, and we thank them for a great project. Twinkql aims to be the MyBatis for the SPARQL community.

More Info

For more info, please see the Project Page and follow us on Twitter.


Twinkql is a SPARQL to Object Mapping Framework that lets you specify your SPARQL queries in XML, instead of in your code, and map the results to Java Beans.






No packages published