Function Name |
Not | ||
Category |
Logic | ||
Icon |
![]() |
||
Description |
Negate an input value, returning its logical "not" | ||
Inputs |
|
||
Outputs |
|
||
Properties |
|
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
|
---|---|
<staff> <employee> <first_name>Mark</first_name> <second_name>Brown</second_name> <started>2001</started> <permanent>true</permanent> </employee> <employee> <first_name>Jane</first_name> <second_name>Jackson</second_name> <started>1998</started> <permanent>true</permanent> </employee> <employee> <first_name>Joe</first_name> <second_name>Simpson</second_name> <started>2008</started> <permanent>false</permanent> </employee> <employee> <first_name>Lynn</first_name> <second_name>Nicolson</second_name> <started>1999</started> <permanent>false</permanent> </employee> </staff> |
For our target schema we will be using staff_target.xsd, inferred from the following XML:
Target XML |
Copy Code
|
---|---|
<company> <staff_member since="2000" contract="false"> <f_name>Ken</f_name> <s_name>Jones</s_name> </staff_member> <staff_member since="2003" contract="true"> <f_name>Linda</f_name> <s_name>Lee</s_name> </staff_member> <staff_member since="1998" contract="false"> <f_name>Paul</f_name> <s_name>Mitchell</s_name> </staff_member> </company> |
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:
Drag the Logic Not function from the Component Palette into the mapping area:
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.
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.
We can now execute the transform by pressing Shift-F5 or the Execute button (). The transform is applied and the file we selected as output opens in the editor:
Output XML |
Copy Code
|
---|---|
<company> <staff_member since="2001" contract="false"> <f_name>Mark</f_name> <s_name>Brown</s_name> </staff_member> <staff_member since="1998" contract="false"> <f_name>Jane</f_name> <s_name>Jackson</s_name> </staff_member> <staff_member since="2008" contract="true"> <f_name>Joe</f_name> <s_name>Simpson</s_name> </staff_member> <staff_member since="1999" contract="true"> <f_name>Lynn</f_name> <s_name>Nicolson</s_name> </staff_member> </company> |
The output contains the negated version of each boolean value in the input.
This is a scalar function so the standard rules apply if multiple values are presented to one or more inputs.