Example: Using File Names as Mapping Parameters

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Designing Mappings > Supplying Parameters to the Mapping >

Example: Using File Names as Mapping Parameters

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\MapForce2019\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


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\MapForce2019\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 %* (as highlighted below). 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.


© 2019 Altova GmbH