Contents: MashupHub User and Administrator Guide : Mashup Center 2.0
For some values to be processed correctly, you must cast the value to an appropriate data type. You can cast a value as a date, decimal, integer, or string.
Displaying the cast menu
Each value in a feed is a string data type by default. For some values to be processed correctly, for example to sort a list of dates or find all values less than the number 100, you must convert the value from a string to the appropriate data type. Use the cast option to convert a value to date, decimal, integer, or string.
Casting works for string values that are in a default format that the data mashup builder recognizes. If the value is not in a default format, then you must convert it using a function that prompts for additional information.
There are two ways to cast a value:
- Right-clicking a value in the input tree of the Properties tab, and selecting the type to cast to.
- Selecting one of the Cast functions from the Functions menu.
Wherever an input tree is available to select a node value, you can right-click it. The input tree is available in many operators and functions. The Extract, Filter, For Each, Group, Merge, Sort, and Transform operators have the input tree. The input tree is also available from any function that takes the input tree as an argument.
In the input tree, to display the cast menu, expand the element that contains the value that you want to cast. Right-click the value, and select the type of cast from the list.
All requests to cast a value or execute a function are expressed in XML. The right-click method and a Cast function option both generate the same <CAST> request.
Casting date elements
When you cast a feed's element value to the date data type, MashupHub converts the element's string value into a datetime type by matching the string format to one of the default sets of datetime formats.
The default formats include the mm/dd/yyyy
format. For Atom feeds, MashupHub supports the ISO 8601 specification. For RSS feeds, MashupHub supports the datetime formats listed in the RFC 822 and RFC 2822 specifications.
If your value is not in one of the supported default formats, convert it using the Create DateTime function.
For details about the supported formats, see Supported date formats : Mashup Center 2.0
Casting numeric elements
When you cast a feed's element to an integer or decimal type, MashupHub converts the element's string value into a numeric type by scanning for numeric digits and the period (.) separator.
If your value is not in this default format, convert it using the Numeric Format function.
Each entry in an RSS feed contains a pubDate
element. The value for this element is a text string. For example: Mon, 28 Apr 2008 12:36:22 EDT
. To compare the pubDate
element with a datetime value, you must cast the value to a date data type. To use the Sort operator to sort feed entries by date, you cast the pubDate
element to perform the sort based on the date data type instead of the string representation of the date.
There are two ways to cast that pubDate
- For the Sort Value choose Specify a value from the input tree. Navigate to the pubDate value, right-click, then select Date.
- For the Sort Value choose Specify a function value. Select Date type. For the input, select Specify a value from the input tree, and then select the pubDate value.
Both ways achieve the same result. For casting a value that is in a default format, the first way is fastest.
When a value is not in the default format, use the second method, but instead of choosing a Cast option, choose the function that converts the value by prompting for additional information, such as the Create DateTime function or the Numeric Format function.
Parent topic: Operators : Mashup Center 2.0
Source operator : Mashup Center 2.0
Filter operator : Mashup Center 2.0
Transform operator : Mashup Center 2.0
Numeric Format function : Mashup Center 2.0
Supported date formats : Mashup Center 2.0