String Functions are used for working with the data of the string data type. These functions allow you to perform operations such as concatenating, obtaining substrings, replacing, and more. In this section, you will find helpful information on the String Functions that available to you as you design your Data Diagrams.
Figure 1: The String Functions available in the Functions dialog.
Usage
To insert a String Function into your Data Diagram, select Functions from the Side Menu to access the Functions Dialog. Here you can scroll to find the String group of functions and select the function of your choice. Once selected, you will notice the Diagram Object for the function is place into the Design Surface. Here you can move, resize, and create data connections to map the flow of your data. In this section, you can find detailed information on each available function.
The Concatenate function is used to concatenate two or more input values into the resulting string. You can add additional parameters for concatenation by right clicking on the function to access the Application Bar. Here you can select Add Parameter. As an example, we will use a database table that contains employee information. We will use the Concatenate function to combine both the FirstName and Lastname fields to create a full name.
Additionally, a constant is added to create a ", " string to be placed between the values and an additional parameter was added by right clicking on the function. The fields and constant are mapped to the function's input parameter data connectors, and the result data connector is mapped to the element sequence in the output data source.
Figure 2: The Concatenate function is used to combine two table fields and a constant.
Figure 3: The output preview reveals the resulting string from the Concatenate function.
The Contains function is useful for testing string inputs for the presence of a specified string value. If the input string contains the specified string, the function will return true. If this test fails, the function will return false.
An example of using the Contains function would be filtering the data set to provide only employees from the sales department. We can use the Contains function to test the Title field to see if it Contains the string "Sales". To do so, we've added the Contains function and specified a constant with value "Sales". The Title field is mapped to the input data connector for content, and the "Sales" constant is mapped to the input data connector for substring. The result output data connector is mapped to the filter-rule input data connector in our filter function.
Figure 4: The Contains function is used to test for the presence of the Sales substring.
Figure 5: The output preview reveals only records with title values containing "Sales".
The Substring function is useful for obtaining a string value from an input string data source. This function has input data connectors for the input string, the starting position of the substring, and the size (how many characters from the starting position).
An example highlighting this usage is if we wanted to only obtain the birth year from a date field specifying birth date. In this example, we first add a conversion function to convert the field to a string. Next we add constants for both the position and the size. These values are set for 0 (position) and 4 (size) to obtain the first four characters from our input string. The To String function result is mapped to the string input data connector and the constants are mapped to both corresponding data connectors for position and size. The result output data connector is mapped to our element sequence in the output XML.
Figure 6: The Substring function is used to obtain the first four characters from the input string.
Figure 7: The output preview reveals the substring taken from the birthdate field.
The Replace function is useful for finding a string within an input string value and replacing with another specified string. The function contains input data connectors for the input string, the string to search for, and the string that will replace the found value.
To demonstrate this usage, we take an example where due to corporate structuring, our reports need to now reflect any job titles for "Sales Representative" as "Sales Agent". We first created two constants, one for the search string of "Representative" and another for "Agent" which will replace the found value. After inserting the Replace function, the Title field is mapped to the input string data connector, the "Representative" constant is mapped to the tofindString data connector, and the "Agent" constant is mapped to the replaceString data connector. The result output data connector is mapped to the element sequence in the output XML.
Figure 8: The Replace function is used to replaced a string in the output.
Figure 9: The output preview reveals the revised title with replaced string values.
The Starts With function is useful for testing an input string to return true if it starts with a specified string. This function has input data connectors for the input string and the substring to be used for search.
To demonstrate this usage, we will use a scenario where we only wish to obtain data on our employees whose last name Starts With a 'P'. After inserting the Starts With function, we set a string constant with a value of 'P' and map this to the substring input data connector of the function. Next we map the LastName field to the input data connector for our function. This function is used as the input for the Filter used to filter the data set.
Figure 10: The Starts With function is used to look for values that start with 'P'.
Figure 11: The output preview reveals there is one employee whose last name begins with 'P'.
The Ends With function is useful for testing an input string to return true if it ends with a specified string. This function has input data connectors for the input string and the substring to be used for search.
To demonstrate this usage, we will use a scenario where we only wish to obtain data on our employees whose title is that of a "Representative" regardless of what department. After inserting the Ends With function, we set a string constant with a value of "Representative" and map this to the substring input data connector of the function. Next we map the Title field to the input data connector for our function. This function is used as the input for the Filter used to filter the data set.
Figure 12: The Ends With function is used to test for Titles ending with Representative.
Figure 13: The output preview reveals the filtered data set for only employees with titles ending with "Representative".
The Length function is used to obtain the number of characters present in a specified input string. The function has an input data connector for the input string and an output data connector to map the result to the data output.
To demonstrate the usage of this function, we will use the LastName field as the input string and map the result output data connector to the element sequence in the output XML.
Figure 14: The Length function is used to return the length of the Last Name field value.
Figure 15: The preview output reveals the length of the last name values.
The Is Empty function is used to test if the string input value is empty, and if so, will return the Boolean value true. Otherwise, the function will return false. This function only requires the input string to be mapped to the string input data connector. The result can be used for filtering and other test functions. In this example, we show how the Is Empty function is used to test for any employees that are missing the LastName field in their record.
Figure 16: The Is Empty function is used to test for any employees missing the Last Name information.
The Is Not Empty function is used to test if the string input value is not empty, and if so, will return the Boolean value true. Otherwise, the function will return false. The function only requires the input string to be mapped to the string input data connector. The result can be used for filtering and other test functions. In this example, we use the Is Not Empty function to ensure that any data presented in our output does not contain empty values for LastName.
Figure 17: The Is Not Empty function is used to ensure the output does not contain empty last name fields.
Figure 18: The results reveal only employees whose last name fields are not empty.