METAmorphoses
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

About

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.

Concepts

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

Requirements

Features

METAmorphoses mapping and data trasformation cover:

Installation

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.

Usage

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(
					templateStream,
					System.out,
					variables
					);
tp.parse();

See JavaDoc in the release for more information about API.

Standalone application

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

Usage: 
  java -jar metamorphoses-v0.2.5.jar <template> [-l <variables>] [<output>]
Where:
  <template>
        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'
  [<output>]
        An output RDF file.

Example:
$ METAmorphoses.sh ../sample/mm_sampl_person.xml -l username=svihlam svihlam_output.rdf

Documentation

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.

Examples

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

Mapping document

<Mapping>
  <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="http://www.w3.org/2001/XMLSchema#string"/>
	</Property>
    <Property templateName="currentProject" rdfLabel="foaf:currentProject" sqlName=""/>
  </Class>

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

Template document

<Template>
  <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"/>
        </Condition>
        <PutProperty name="projectHomepage"/>
      </PutInstance>
    </PutProperty>
  </PutInstance>
</Template>

Final RDF

<foaf:Person>
  <foaf:surname rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Svihla</foaf:surname>
  <foaf:currentProject>
    <foaf:Project>
      <foaf:homepage>http://www.svihla.net/metamorphoses/</foaf:homepage>
    </foaf:Project>
  </foaf:currentProject>
</foaf:Person>

Licence

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.