Returning String Values from a Mapping

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

Home >  Designing Mappings >

Returning String Values from a Mapping

Use a simple output component when you need to return a string value from the mapping. On the mapping area, simple output components play the role of a target component which has a string data type instead of a structure of items and sequences. Consequently, you can create a simple output component instead of (or in addition to) a file-based target component. For example, you can use a simple output component to quickly test and preview the output of a function (see Example: Testing Function Output).

 

Simple output components should not be confused with output parameters of user-defined functions (see User-Defined Functions). There are some similarities and differences between the two, as follows.

 

Output components

Output parameters of user-defined functions

Added from Function | Insert Output menu.

Added from Function | Insert Output menu.

Have "string" as data type.

Can have simple as well as complex data types.

Applicable to the entire mapping.

Applicable only in the context of the function in which they were defined.

 

If necessary, you can add multiple simple output components to a mapping. You can also use simple output components in combination with file-based target components. When your mapping contains multiple target components, you can preview the data returned by a particular component by clicking the Preview ( ic-preview ) button in the component title bar, and then clicking the Output tab on the Mapping window.

 

You can use simple output components as follows in MapForce transformation languages:

 

Language

How it works

XSLT 1.0, XSLT 2.0

If the generated XSLT files, a simple output components defined in the mapping becomes the output of the XSLT transformation.

 

If you are using RaptorXML Server, you can instruct RaptorXML Server to write the mapping output to the file passed as value to the --output parameter.

 

To write the output to a file, add or edit to the --output parameter in the DoTransform.bat file. For example, the following DoTransform.bat file has been edited to write the mapping output to the Output.txt file (see highlighted text).

 

RaptorXML xslt --xslt-version=2 --input="MappingMapToResult1.xslt" --output="Output.txt" %* "MappingMapToResult1.xslt"

 

If an --output parameter is not defined, the mapping output will be written to the standard output stream (stdout) when the mapping is executed.

 

When you create a reversed mapping (using the menu command Tools | Create Reversed Mapping), the simple output component becomes a simple input component.


© 2019 Altova GmbH