Liquid XML Studio
See Also Send Feedback
Data Mapping > Data Mapper Functions > By Category > Type > NodeType

Glossary Item Box

Function Name
Retrieve the type of an input value
Value Input value to determine type of
Type Type of input value represented as String
None -


The Data Mapper Type function returns the type of a particular input value as a String. When mapping data, it is of course possible that your target application will not have awareness of the details of input data values, in which case you may need to determine data types before making use of your mapped values. The Type function can recognise various numerical types, booleans, Strings, binary/ bytes and date/ time types, as indicated in XSDs. To apply the Type function, use the following process:

Create a new Data Mapper file, dragging your XML data source and targets into the editor area. For this example we are using value_types_source.xsd, an XML Schema Definition inferred from the following source:

Source XML Copy Code
 <section name="Objects">
 <section name="Colors">

For our target schema we will be using value_types_target.xsd, inferred from the following XML:

Target XML Copy Code

The data models values within sections, with the target including an element indicating the data types contained within the file. We are going to determine the type of the "item" element content, which in this case is String. The "data_type" element in the target will include an indicator of this data type. Here is the Data Mapper with Source and Target imported:

Data Mapper Source and Target

Drag the Type function from the Component Palette into the mapping area:

Type Component

Type Transform Added

The Type function takes a single input and gives an output indicating the type in question. The input should be connected to the source item you want to determine type from. The output should be connected to the target item, whether an item in the XML Writer or another component in the Mapper.

Connect the Type function output to the "data_type" input in the XML Writer.

Type to Writer

We have input data with multiple elements of the type we are interested in, so we only need one to determine the type from. To achieve this, let's drag a First function from the Set section of the Component Palette - this will return the first instance of the specified item within the source data. Connect the Nodes input of the First function to the "item" element in the XML Reader, since this is the element we are interested in.

XML Reader to First

This function will retrieve the first "item" element in the input data, so let's connect its output to the Value input of the Type function.

First to Type

Finally, connect the remaining inputs and outputs, remembering to map "item" to "value_item", meaning that the "item" output is connecting to two different inputs:

Input and Output Connections Mapped

We can now execute the transform by pressing Shift-F5 or the Execute button (Execute). The transform is applied and the file we selected as output opens in the editor:

Output XML Copy Code

The type of the first "item" element has been mapped to the "data_type" element in the target as part of the mapping process. The result is that the output data now includes an indicator of the types of data item being handled.

Possible output values of the Type function include: Binary, Boolean, Byte, DateTime, DateTimeOffset, Decimal, Double, Float, Guid, Int16, Int32, Int64, SByte, String, Time and Node.

See Also