Liquid Studio 2020
Data Mapping / Data Mapper Functions / By Category / Logic / True
In This Topic
    True
    In This Topic

    Function Name
    True
    Category
    Logic
    Icon
    True
    Description
    A boolean true value
    Inputs
    None -
    Outputs
    Result A constant boolean value of true
    Properties
    None -

    Usage

    The Data Mapper Logic True component allows you to feed a literal boolean value directly into your Mapping functions and output. Since the True function outputs a boolean, you may also use it in conjunction with other functions in the Set, Logic and Comparator categories. To apply the Logic True 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_alt_target.xsd, inferred from the following XML:

    Target XML
    Copy Code
    <company>
     <staff_member since="2000" contract="false" certified="true">
      <f_name>Ken</f_name>
      <s_name>Jones</s_name>
     </staff_member>
     <staff_member since="2003" contract="true" certified="false">
      <f_name>Linda</f_name>
      <s_name>Lee</s_name>
     </staff_member>
     <staff_member since="1998" contract="false" certified="true">
      <f_name>Paul</f_name>
      <s_name>Mitchell</s_name>
     </staff_member>
    </company>
    

    The data models employees within an organisation. Notice that the target data model contains a value that is not in the source: the "certified" attribute of the "staff_member" element, representing some sort of work-related certification status. Let's assume that we are mapping data records for employees we know are all certified, perhaps due to which department they are in or where the data has been retrieved from. This means that we know all records should be output with a value of true for the attribute, and can use the True component to define this. Here is the Data Mapper with Source and Target imported:

    Data Mapper Source and Target

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

    True Component

    True Added

    The True component has no inputs, and a single output which is always a boolean true value. The output of the True function may be connected to items in the XML Writer or other components in the Mapper.

    Connect the output of the True function to the "certified" input in the XML Writer.

    True Mapped

    Now each boolean value in the "certified" element will be true for the data being mapped. 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
    <company>
     <staff_member since="2001" contract="true" certified="true">
      <f_name>Mark</f_name>
      <s_name>Brown</s_name>
     </staff_member>
     <staff_member since="1998" contract="true" certified="true">
      <f_name>Jane</f_name>
      <s_name>Jackson</s_name>
     </staff_member>
     <staff_member since="2008" contract="false" certified="true">
      <f_name>Joe</f_name>
      <s_name>Simpson</s_name>
     </staff_member>
     <staff_member since="1999" contract="false" certified="true">
      <f_name>Lynn</f_name>
      <s_name>Nicolson</s_name>
     </staff_member>
    </company>
    

    The output contains the input data plus a true value for each staff member "certified" attribute.

    See Also

    Values