Liquid XML Studio
See Also Send Feedback
Data Mapping > Data Mapper Functions > By Category > Logic > Not

Glossary Item Box

Function Name
Negate an input value, returning its logical "not"
Input Input boolean value to negate
Result Logical "not" value of input
None -


The Data Mapper Logic Not function allows you to negate boolean values from your input data. If the Not function receives an input value of true it will output false. If it receives a false input value it will output true. The Not function can be useful in cases where the data model differs logically within the target application. Since the Not function outputs a boolean value, you may also use it in conjunction with other functions in the Set, Logic and Comparator categories. To apply the Logic Not 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 staff_source.xsd, an XML Schema Definition inferred from the following source:

Source XML Copy Code

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

Target XML Copy Code
 <staff_member since="2000" contract="false">
 <staff_member since="2003" contract="true">
 <staff_member since="1998" contract="false">

The data models employees within an organisation. Let's assume that, in the source data, "permanent" refers to whether or not an employee has a permanent contract, but in the target, "contract" refers to whether employees have temporary contracts. In effect, we are mapping values which equate to the opposite in source and target. For this reason we want to negate the incoming "permanent" value and write it to the "contract" output. I.E. if someone does not have a permanent contract, they have a temporary one, so they have a false "permanent" value in the source, but a true "contract" value in the target. Here is the Data Mapper with Source and Target imported:

Data Mapper Source and Target

Drag the Logic Not function from the Component Palette into the mapping area:

Not Component

Not Added

The Not function takes a single input, the boolean value to negate. The output contains the "not" of the input value. Both input and output of the Not function may be connected to items in the XML Reader/ Writer or other components in the Mapper.

Connect the input of the Not function to the "permanent" output in the XML Reader, and the Not output to the "contract" input in the XML Writer.

Not Mapped

Now each boolean value in the "permanent" inputs will be output as "contract" attributes containing the opposite value. Finally let's make the remaining input and output connections.

Inputs and Outputs Connected

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
 <staff_member since="2001" contract="false">
 <staff_member since="1998" contract="false">
 <staff_member since="2008" contract="true">
 <staff_member since="1999" contract="true">

The output contains the negated version of each boolean value in the input.

You can combine the Not function with other Comparator and Logic functions to create complex chains of conditional tests.

This is a scalar function so the standard rules apply if multiple values are presented to one or more inputs.

See Also