Please enable JavaScript to view this site.

Altova MapForce 2020 Enterprise Edition

This example walks you through the steps required to execute a mapping that takes input parameters at runtime. The mapping design file used in this example is available at the following path: <Documents>\Altova\MapForce2020\MapForceExamples\FileNamesAsParameters.mfd.


The mapping uses two input components: InputFileName and OutputFileName. These supply the input file name (and the output file name, respectively) of the source and target XML file. For this reason, they are connected to the File: <dynamic> item.


FileNamesAsParameters.mfd (MapForce Basic Edition)

Both the InputFileName and OutputFileName components are simple input components in the mapping, so you can supply them as input parameters when executing the mapping. The following sections illustrate how to do this in the following transformation languages:


XSLT 2.0, using RaptorXML Server

Built-in (MapForce Server Execution File), using MapForce Server



XSLT 2.0

If you generate code in XSLT 1.0 or XSLT 2.0, the input parameters are written to the DoTransform.bat batch file, for execution by RaptorXML Server (see Automation with RaptorXML Server). To use a different input (or output) file, you can either pass the required parameters at command line, when calling the DoTransform.bat file, or edit the latter to include the required parameters.


To supply a custom input parameter in the DoTransform.bat file:


1.Generate the XSLT 2.0 code (File | Generate Code In | XSLT 2.0) from the FileNamesAsParameters.mfd sample.

2.Copy the Altova_Hierarchical.xml file from the <Documents>\Altova\MapForce2020\MapForceExamples\ directory to the directory where you generated the XSLT 2.0 code (in this example, c:\codegen\examples\xslt2\). This file will act as custom parameter.

3.Edit DoTransform.bat to include the custom input parameter either before or after %*. Note that the parameter value is enclosed with single quotes. The available input parameters are listed in the rem (Remark) section.

@echo off


RaptorXML xslt --xslt-version=2 --input="MappingMapToAltova_Hierarchical.xslt" --param=InputFileName:'Altova_Hierarchical.xml' %* "MappingMapToAltova_Hierarchical.xslt"

rem --param=InputFileName:

rem --param=OutputFileName:


When you run the DoTransform.bat file, RaptorXML Server completes the transformation using Altova_Hierarchical.xml as input parameter.



MapForce Server Execution File

To supply custom input parameters to a MapForce Server execution file:


1.Compile the FileNamesAsParameters.mfd to a MapForce Server execution file (see Compiling Mappings to MapForce Server Execution Files). When prompted, save the .mfx execution file to a directory on your computer (in this example, c:\codegen\examples\mfx\ ).

2.Copy the Altova_Hierarchical.xml file from the <Documents>\Altova\MapForce2020\MapForceExamples\ directory to the directory where you saved the .mfx file. This file will act as the custom parameter supplied to the mapping execution file.

3.Run MapForce Server with the following command:

MapForceServer.exe run "C:\codegen\examples\mfx\FileNamesAsParameters.mfx" -p=InputFileName:"C:\codegen\examples\mfx\Altova_Hierarchical.xml" -p=OutputFileName:"C:\codegen\examples\mfx\OutputFile.xml"

In the MapForce Server command above, -p=InputFileName and -p=OutputFileName are the input parameters to the mapping. You can use any file name as the value of -OutputFileName. However, the file name supplied in -InputFileName parameter must exist as a physical file; otherwise, the mapping will fail.


Note:If you see the message "MapForceServer.exe is not recognized as an internal or external command, operable program, or batch file", change the current directory to the one where the MapForce Server executable is installed. To avoid changing path every time when you run a mapping, add to your operating system's PATH environment variable the path of the directory where MapForce Server executable is installed (for example, C:\Program Files (x86)\Altova\MapForceServer2020\bin) .



To supply a custom input parameter to a Java .jar application:


1.Generate the Java code (File | Generate Code In | Java) from the FileNamesAsParameters.mfd sample.

2.Compile the Java code into an executable JAR file (for instructions on how to do this in Eclipse, see Example: Generate and Run Java Code).

3.Copy the Altova_Hierarchical.xml file from the <Documents>\Altova\MapForce2020\MapForceExamples\ directory to the directory where the .jar file is. This file will act as the custom parameter supplied to the Java mapping application.

4.At the command line, enter: java -jar Mapping.jar /InputFileName "InputFile.xml"

If you use wildcards when passing parameters to .jar files, place the wildcard parameters in quotes, for example:


java -jar Mapping.jar /InputFileName "altova-*.xml"


© 2020 Altova GmbH