Please enable JavaScript to view this site.

Altova MapForce 2020 Professional Edition

This topic describes how to create a sample Java library and configure a .mff file for it so that the library appears in the Libraries window of MapForce.


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

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


    package com.hello.functions;
    public class Hello {
        public static String HelloFunction ( boolean greetingType ) {
          if( greetingType )
              return "Hello World!";
          return "Hello User!";


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 folder. Make sure that the text highlighted below points to the namespace and class defined previously in the Java code. For more information, see Configuring the .mff File.


<?xml version="1.0" encoding="UTF-8"?>
<mapping version="9" library="helloworld" xmlns:xs="" xmlns:xsi="" xsi:noNamespaceSchemaLocation="mff.xsd">
    <implementation language="java">
        <setting name="namespace" value="com.hello.functions"/>
        <setting name="class" value="Hello"/>        
  <group name="Greetings">
    <component name="HelloFunction">
          <datapoint name="greeting_type" type="xs:boolean"/>
          <datapoint name="result" type="xs:string"/>
          <implementation language="java">
              <function name="HelloFunction"/>
          <short>result = hello(greeting_type)</short>
          <long>Returns a greeting according to the given greeting type.</long>


You have now finished creating a custom library and the .mff file which adapts it to MapForce. The custom .mff file can now be used in MapForce (see Importing the .mff File Into MapForce).

© 2019 Altova GmbH