MapForce Command-Line Interface
The MapForce command-line interface enables you to automate tasks such as:
•Opening mappings
•Generating mapping code
•Compiling mappings for MapForce Server (Professional and Enterprise editions)
•Generating code for projects (Professional and Enterprise editions)
•Creating log files
•Comparing two mappings
Syntax
The syntax for the command line is as follows:
MapForce.exe <filename> [/{target} [[<outputdir>] [/options]]]
How to run commands
To run commands at the command line, switch to the installation directory of MapForce. For example:
C:\Program Files\Altova\MapForce2027
For more information about each parameter of the command, see Parameters below.
Notation
The following notation is used to indicate command-line syntax:
Notation | Description |
|---|---|
Text without brackets or braces | Items you must type as shown |
<Text inside angle brackets> | Placeholder for which you must supply a value |
[Text inside square brackets] | Optional items |
{Text inside braces} | Set of required items; choose one |
Vertical bar (|) | Separator for mutually exclusive items; choose one |
Ellipsis (...) | Items that can be repeated |
Parameters
<filename>
Refers to the mapping design (.mfd) or mapping project (.mfp) (Professional and Enterprise editions) from which code is to be generated. To generate code for the whole project, set the target /GENERATE (see /{target} below) and enter the project path as <filename> (e.g., MapForceExamples.mfp).
/{target}
Specifies the target language or environment for which code is to be generated. The table below summarizes the supported code-generation targets.
Code-generation target | Description |
|---|---|
/XSLT | |
/XSLT2 | |
/XSLT3 | |
/COMPILE[:compileoptions] | Compiles a mapping to a MapForce Server execution file (.mfx). You can also supply the following options separated by a comma:
•The JDBC option transforms all database connections to JDBC using the JDBC driver and the database URL defined in the Database Component Settings dialog. •The NOXMLSIGNATURES option suppresses the generation of digital signatures in the MapForce Server Execution file. Note that digital signatures are not supported by MapForce Server.
|
/GENERATE | Generates project code for all mappings in the project file, using the current folder settings (see Managing Project Folders). If you select this target, supply a MapForce project (.mfp) as <filename>.
|
/XQuery | |
/JAVA | |
/CS | Generates C# code. This command allows setting the following code generation options:
/CS[:{VS2013|VS2015|VS2017|VS2019|VS2022|DOTNETCORE31|DOTNET50|DOTNET60}]
If no Visual Studio version is specified, code will be generated using the Visual Studio version defined in the code generation options.
|
/CPP | Generates C++ code. This command allows setting the following code generation options:
/CPP[:{VS2013|VS2015|VS2017|VS2019|VS2022|DOTNETCORE31|DOTNET50|DOTNET60},{MSXML|XERCES3},{LIB|DLL},{MFC|NoMFC}]
The first group of options specifies the development environment (e.g., VS2022 stands for Visual Studio 2022).
The second group of options specifies the XML library targeted by the generated code. The following values are valid:
•MSXML (generates code for MSXML 6.0) •XERCES3 (generates code for Xerces 3)
The third group of options specifies whether static or dynamic libraries should be generated. Valid values include the following:
•LIB (generates static LIB libraries) •DLL (generates DLL libraries)
The fourth group of options specifies whether code should be generated with or without MFC support. Valid values include the following:
•MFC (enables MFC support) •NoMFC (disables MFC support)
If the options above are not specified, code will be generated using the Visual Studio version defined in the code generation options.
|
<outputdir>
Optional parameter that specifies the output directory. If not supplied, the current working directory is used. Relative paths are relative to the current working directory.
With the target set to /GENERATE, the following applies:
•If <outputdir> is not specified, the code generation language and output path defined for each project folder are used (see Project Folders).
•If <outputdir> is specified, it overrides the output directory defined at the root project level, but not the code generation settings defined for individual project folders.
One or more of the following options can be set.
Option | Description |
|---|---|
/DIFF | Enables you to compare an older and a newer version of the same mapping. For details, see Mapping Difference. To compare two mapping versions at the command line, use the following command:
MapForce.exe <newer-mapping>.mfd /DIFF <older-mapping>.mfd
|
/DIFFREPORT <report> | Generates an XML file describing the differences between the mappings specified with the /DIFF option.
To generate an XML report of the differences between two mappings, you must use /DIFF and /DIFFREPORT together:
MapForce.exe <newer-mapping>.mfd /DIFF <older-mapping>.mfd /DIFFREPORT <report>.xml
When /DIFFREPORT is used, MapForce does not open the main window. The report file is generated whether the mappings are identical or contain differences.
The command returns one of the following exit codes:
•0 – The mappings are identical. •1 – The mappings are different. •2 – An error occurred during the comparison.
Note: When you run MapForce from a Windows Command Prompt, use start /wait to wait for MapForce to finish before retrieving the exit code with %ERRORLEVEL%. For example:
start "" /wait MapForce.exe <newer-mapping>.mfd /DIFF <older-mapping>.mfd /DIFFREPORT <report>.xml echo %ERRORLEVEL%
Otherwise, the command prompt may not wait for MapForce to finish, and %ERRORLEVEL% may not contain the MapForce exit code. In a batch file, the command prompt waits for MapForce to finish, so start /wait is not required.
|
/GLOBALRESOURCEFILE <filename> | Applicable if the mapping uses Global Resources to resolve an input/output file, folder paths, or databases. For more information, see Altova Global Resources. Specifies the path to a Global Resource XML file. If /GLOBALRESOURCEFILE is set, /GLOBALRESOURCECONFIG must also be set.
|
/GLOBALRESOURCECONFIG <config> | Specifies the name of the Global Resource configuration. If /GLOBALRESOURCEFILE is set, then /GLOBALRESOURCECONFIG must also be set.
|
/LOG <logfilename> | Generates a log file at the specified path. If an absolute path is specified, the directory must exist. If only a file name is specified, the log file is created in the current directory of the Windows Command Prompt.
|
[/MFXVERSION[:<version>] | Applicable if the target is /COMPILE. Compiles the MapForce Server Execution (.mfx) file for a particular version of MapForce Server. You can specify any MapForce Server version from 2013r2 onwards. See also Compiling Mappings for a Specific MapForce Server Version.
|
/LIBRARY <libname> (...) | Used together with a code generation target language to specify additional function libraries. This option can be specified more than once to load multiple libraries. See also Managing Function Libraries.
|
Notes
•Relative paths are relative to the current directory of the application calling MapForce. This applies to the path of the .mfd and .mfp file paths, output directory, log file, and Global Resource file.
•Do not use a trailing backslash before the closing quotation mark at the command line (e.g., "C:\My directory\"). The command line parser interprets the backslash and closing quotation mark as a literal double quotation mark. If a path contains spaces and must be enclosed in quotation marks, use a double backslash before the closing quotation mark (e.g., "c:\My Directory\\").
Examples
1) To start MapForce and open the mapping <filename>.mfd, use the following command:
MapForce.exe <filename>.mfd
2) To generate XSLT 2.0 code and create a log file with the name <logfilename>, use the following command:
MapForce.exe <filename>.mfd /XSLT2 <outputdir> /LOG <logfilename>
3) To generate XSLT 2.0 code taking into account the global resource configuration <grconfigname> from the global resource file <grfilename>, use the following command:
Mapforce.exe <filename>.mfd /XSLT2 <outputdir> /GLOBALRESOURCEFILE <grfilename> /GLOBALRESOURCECONFIG <grconfigname>
Examples for Professional and Enterprise editions
1) To generate a C# application for Visual Studio 2022 and output a log file, use the following command:
MapForce.exe <filename>.mfd /CS:VS2022 <outputdir> /LOG <logfilename>
2) To generate a C++ application using the code generation settings defined in Tools | Options and output a log file, use the following command:
MapForce.exe <filename>.mfd /CPP <outputdir> /LOG <logfilename>
3) To generate a C++ application for Visual Studio 2022, MSXML, with static libraries, MFC support, and no log file, use the following command:
MapForce.exe <filename>.mfd /CPP:VS2022,MSXML,LIB,MFC
4) To generate a C++ application for Visual Studio 2022, Xerces, with dynamic libraries, no MFC support, and a log file, use the following command:
MapForce.exe <filename>.mfd /CPP:VS2022,XERCES,DLL,NoMFC <outputdir> /LOG <logfilename>
5) To generate a Java application and output a log file, use the following command:
MapForce.exe <filename>.mfd /JAVA <outputdir> /LOG <logfilename>
6) To generate code for all mappings in the project, using the language and output directory defined in the folder settings (of each folder inside the project), use the following command:
MapForce.exe <filename>.mfp /GENERATE /LOG <logfilename>
7) To generate Java code for all mappings in the project file, use the following command:
MapForce.exe <filename>.mfp /JAVA /LOG <logfilename>
Note that the code generation language defined in the folder settings are ignored, and Java is used for all mappings.
8) To supply input and output files at the command line for a previously compiled Java mapping, use the following command:
java -jar <mappingfile>.jar /InputFileName <inputfilename> /OutputFileName <outputfilename>
The /InputFileName and /OutputFileName parameters are the names of special input components in the MapForce mapping that allow you to use parameters in command line execution (see Supplying Parameters to the Mapping).
9) To compile a mapping to a MapForce Server execution file for MapForce Server version 2027 and suppress XML signatures, use the following command:
MapForce.exe <filename>.mfd /COMPILE:NOXMLSIGNATURES <outputdir> /MFXVERSION:2027 /LOG <logfilename>