Please enable JavaScript to view this site.

Altova MapForce 2021 Enterprise Edition

This example shows you how to create a sample Java library and adapt it to a MapForce Function File (.mff) that can be imported as a MapForce library.


Note:Adapting a Java library to .mff format is just one of the ways to import Java libraries in MapForce. A simpler alternative is to import Java .class files directly, see Example: Import Custom Java Class.


The configuration process consists of the following steps:


1.Create a new Java project in your preferred development environment (for example, Eclipse).

2.Add to the project a new package called com.mylib which consists of a class called Greetings. In the code listing below, notice that the SayHello function has been defined as public static.


package com.mylib;
public class Greetings {
  public static String SayHello ( boolean isMorning ) {
    if( isMorning )
        return "Good Morning!";
    return "Good Day!";


3.Optionally, if your project needs support for special schema types such as date, time, and duration, import the com.altova.types package. To obtain this package, generate Java code from a mapping without custom functions.


import com.altova.types.*;


4.Compile your custom library to a class file, and add it to the Java classpath.

5.Using an XML editor, create a new .mff file and validate it against the ..\Program Files\MapForceLibraries\mff.xsd schema. Make sure that all references under implementation language="java" point to the correct Java members created previously. Also, the line function name="SayHello" must refer to the function name exactly as it was defined in Java, see also Configuring the .mff File.


<?xml version="1.0" encoding="UTF-8"?>
<mapping version="9" library="custom" xmlns:xs="" xmlns:xsi="" xsi:noNamespaceSchemaLocation="mff.xsd">
    <implementation language="java">
        <setting name="package" value="com.mylib"/>
        <setting name="class" value="Greetings"/>
  <group name="greetings">
    <component name="sayhello">
          <datapoint name="ismorning" type="xs:boolean"/>
          <datapoint name="result" type="xs:string"/>
          <implementation language="java">
              <function name="SayHello"/>
          <short>result = sayhello(ismorning)</short>
          <long>Returns "Good morning" or "Good day", depending on the input parameter.</long>


You have now finished creating a custom Java library and the .mff file which adapts it to MapForce. The custom .mff file can now be imported as a library into MapForce, see Importing .mff Libraries.

© 2020 Altova GmbH