DB to RDF transformation for the semantic web

Author: Martin İvihla, martin (at) svihla (dot) net
Home / MMPHP / METAmorphoses processor / RDF-Shout / Schema mapping editor /
Papers / Download

METAmorphoses processor


METAmorphoses processor is a tool for the data transformation -- it transforms data from a relational database into RDF documents according to mapping. In order to enable this, METAmorphoses processes schema mapping and template documents written in our XML languages (see the documentation and Samples.

The processor is implemented using Java and can be used as standalone CLI application or Java library.


The METAmorposes processor is based on the two-layer data transformation model. In order to achieve a flexible data transformation and high usability, the METAmorphoses logic is divided into two separate parts that are called the mapping layer and template layer. In the mapping layer, a given database schema is mapped into a structure of a given ontology. The template layer uses this mapping and produces RDF documents in the way driven by templates.
The mapping layer contains all the complexity and flexibility of mapping. On the other hand, the template layer is a simple programmer interface of the data transformation model.
Architecture of METAmorphoses



METAmorphoses mapping and data trasformation cover:


There is no need to instal. METAmorphoses processor is delivered as source code and as executable .jar library (lib/metamorphoses-v0.2.jar). See next section for the usage instructions.


You can use METAmorphoses as a programming library or as standalone Java application.

Programming library

InputStream templateStream = new FileInputStream(templateFileName);
HashMap variables = new HashMap();
variables.put("variableName", "variableValue");
TemplateProcessor tp =
				new TemplateProcessor(

See JavaDoc in the release for more information about API.

Standalone application

From METAmorphoses root directory do
$ cd bin/
$ (or .bat in MS Windows)

  java -jar metamorphoses-v0.2.5.jar <template> [-l <variables>] [<output>]
        A path to a particular template file.
  [-l <variables>]
        A list of variables required by the processed template. 
        Format: comma separated list of pairs 'variableName=variableValue'
        An output RDF file.

$ ../sample/mm_sampl_person.xml -l username=svihlam svihlam_output.rdf


The METAmorphoses data transformation is based on two kinds of XML files: mapping files (that contain mapping between database schema ane RDFS/OWL ontology) and template files (queries or RDF views to relational database).
See the documentation and samples in the following section on how to create such files.


Following simple examples illustrates the mapping and teplate documents. There is also a functional sample available in the METAmorphoses release.

Mapping document

  <Class templateName="person" rdfLabel="foaf:Person" sql="select * from person">
    <ClassCondition templateName="username" whereString="username ="/>
    <Variable templateName="personId" sqlName="id"/>
    <Property templateName="surname" rdfLabel="foaf:surname" sqlName="family_name">
	  <Attribute rdfLabel="rdf:datatype" prefix=""/>
    <Property templateName="currentProject" rdfLabel="foaf:currentProject" sqlName=""/>

  <Class templateName="project" rdfLabel="foaf:Project" sql="select * from project p, person_project pp where = pp.project_id">
    <ClassCondition templateName="personId" whereString="pp.person_id ="/>
    <Property templateName="projectHomepage" rdfLabel="foaf:homepage" sqlName="web"/>

Template document

  <Mapping url="mapping.xml"/>
  <PutInstance name="person" id="1">
    <Condition name="username">svihlm1</Condition>
    <PutProperty name="surname"/>
    <PutProperty name="currentProject">
      <PutInstance name="project">
        <Condition name="personId">
          <Variable id="1" name="personId"/>
        <PutProperty name="projectHomepage"/>

Final RDF

  <foaf:surname rdf:datatype="">Svihla</foaf:surname>


The project is being developed under Lesser GPL licence.

This is the short clarification of the licence:
METAmorphoses is Free Software. The LGPL license is sufficiently flexible to allow the use of METAmorphoses in both open source and commercial projects. Using METAmorphoses (by importing METAmorphoses's public interfaces in your Java code), and extending METAmorphoses (by subclassing) are considered by the authors of METAmorphoses to be dynamic linking. Hence our interpretation of the LGPL is that the use of the unmodified METAmorphoses source or binary, or the rebundling of unmodified METAmorphoses classes into your program's .jar file, does not affect the license of your application code.
If you modify METAmorphoses and redistribute your modifications, the LGPL applies.