Altova MapForce 2024 Professional Edition

Code Generator is a MapForce built-in feature which enables you to generate code from mapping files. You can use the generated code to execute your mappings outside of MapForce, which will enable you to automate your mapping operations. You can generate code in the following data transformation languages:


XSLT 1.0/XSLT 2.0/XSLT 3.0 (all editions)

XQuery (Professional and Enterprise editions)

Java (Professional and Enterprise editions)

C# (Professional and Enterprise editions)

C++ (Professional and Enterprise editions)


You can generate code from a single mapping design (.mfd) or from a mapping project (.mfp). Code generation from a project is supported only in Professional and Enterprise editions. For details, see the subsections below.


Important points

Note the following code-generation aspects:


Certain MapForce features are not supported in generated program code. For details, see Supported features in generated code.

For information about handling paths in generated code, see Paths in Execution Environments.

Professional and Enterprise editions: You can change general code-generation options in the Generation section of the Options dialog. For details, see Generation.

Professional and Enterprise editions: Support for database connections varies depending on the platform, and there are connection types that are not supported on all platforms. If your mapping connects to a database, choose a database connection that is compatible with the target environment for which you generate code. For details, see Database mappings in various execution environments.


Support information

The table below summarizes support information about C++, C#, and Java.


Target Language




Development environments

Microsoft Visual Studio 2013, 2015, 2017, 2019, 2022

Microsoft Visual Studio 2013, 2015, 2017, 2019, 2022


Target frameworks:


.NET Framework

.NET Core 3.1

.NET 5.0

.NET 6.0

.NET 8.0

Java SE JDK 8, 11, 17, 21 (including OpenJDK)

Eclipse 4.4 or later

Apache Ant

XML DOM implementations


Apache Xerces 3



Database API





Generate code from a mapping

To generate code from a mapping design (.mfd), follow the instructions below:


1.Select the relevant code-generation options in the Generation section of the Options dialog (applicable to C# and C++) and in the Mapping Settings. For details about the code-generation settings in the Options dialog, see Generation.

2.Click File | Generate code in and select the relevant transformation language. Alternatively, you can select File | Generate Code in Selected Language. In this case, code will be generated in the language selected in the toolbar.

3.Select a destination directory for the generated files and then click OK to confirm. MapForce generates the code and displays the result of the operation in the Messages window.


Generate code from a project (Professional and Enterprise editions)

You can generate code from a mapping project (.mfp) that consists of multiple mapping design files (.mfd). Note that all mapping design files in the project must qualify for generation, which means that all their components must be supported in the selected transformation language (see Supported features in generated code).


To generate code from a mapping project, follow the instructions below.


1.Open the relevant mapping project, for which you wish to generate code.

2.Right-click the project name in the Project window and then select Properties from the context menu. Alternatively, click the project name and select the Project | Properties menu item.

3.Review and change the project settings if required. In particular, ensure that the target language and the output directory are set correctly. Then click OK.

4.Click Generate Code for Entire Project in the Project menu.


Irrespective of the language selected in the Project Properties dialog, you can always choose to generate project code in a different language, by selecting the menu command Project | Generate Code in | <language>.


The progress and result of the code generation process are displayed in the Messages window. By default, the name of the generated application is the same as the project name. If the project name contains spaces, these are converted to underscores in the generated code. By default, code is generated in the same directory as the MapForce project, in the output sub-directory.


You can change the output directory and/or the name of the project in the Project Properties dialog. If your MapForce project contains folders, you can configure the code generation settings for each individual folder: Right-click a folder of interest and select Properties from the context menu. Otherwise, all project folders inherit the settings defined at top level. For more information about projects and project-related settings and procedures, see Projects.


Next steps

Depending on the transformation language you have selected for code generation, the subsequent steps vary. If you have generated code in XSLT 1-3 or XQuery, the next step will be to run the transformation from the command line (see details below).


If you have generated Java, C#, or C++ code, the next steps will be to build and run the generated code. For more information about these procedures, see Code Generator. You can also modify the generated Java, C#, and C++ code and integrate it into your custom code. For details, see Integrate Generated Code.


XSLT and XQuery code

After you have generated XSLT 1-3 code, the destination folder will include the following files:


1.An XSLT transformation file that has the following format: <Mapping>MapTo<TargetFileName>.xslt. <Mapping> is the value of the Application Name field in the mapping settings. <TargetFileName> is the name of the target component. To change this value, open the settings of the target component and edit the value of the Component Name field. For more information, see Change Component Settings and Library paths in generated code.

2.A DoTransform.bat file, which enables you to run the XSLT transformation with Altova RaptorXML Server from the command line. In order to run the command, you will need to install RaptorXML.


If your mapping is chained, a separate transformation file will be generated for each target component.


XQuery code generation is similar to XSLT code generation, except that the transformation file(s) have a .xq extension and the following format: <Mapping>MapTo<TargetFileName>.xq.


© 2018-2024 Altova GmbH