Liquid Studio Documentation
In This Topic
    In place casting
    In This Topic

    Casting rules can be applied to an input connection point, allowing the input data to be converted before it is processed by the component.

    This is typically used to convert string data into one of the following types binary, date, datetime, time or timespan. It can also be used to refine the input type for a component, i.e. some components accept generic types, any, atomic or numeric. The type can be changed before it reaches the component providing more control, so you could ensure that a component that accepted a numeric type always dealt with it as an Int64.


    In this example this source data is a string and the target data type is 'Date'.

    Source Data
    Copy Code
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Created with Liquid XML Studio ( -->
    <Strings xmlns:xsi="" xsi:noNamespaceSchemaLocation="..\..\Common\Numbers.xsd">

    The input data contains dates in US format (YYYY/DD/MM), without the cast the default string to date rules are applied which assume it's in XSD xs:date format. The result would be a runtime error as the value '2014/01/02' is not a valid XSD xs:date.

    So we need to apply a cast to the input data to allow it to be converted to a Date.

    We do this on the properties window, first select the input connection point 'Date'.

    Then select the "Cast Type" in the properties window.

    As the target type is explicitly a Date, we have only one option.

    Once a 'Cast Type' has been selected a new option appears 'Cast Conversion Rule', select this and click the '...' button.

    This presents a 'Casting Rules' dialog with a number of options for converting to a string to a Date.

    We will select the 'Customizable DateTime' option.

    The dialog presents some common specifiers, have a look at Standard Date and Time Format Strings & Custom Date and Time Format Strings for more information about them.

    The parser will match the first 'Format Specifier' to match the expression, so we can replace them all with yyyy'/'dd'/'MM.

    We could also use the Format Specifier 'd' which matches a date, but it works very differently in with different local settings so if you use the general format specifiers be careful to consider the local settings.

    When an inline cast has been setup against a connection point input it is noticeable on the diagram as the name is post fixed with the type in brackets.

    Now when we run the transform we get the output we expect.

    Transform Output
    Copy Code
    The output type is an xs:date, so the output is formatted according to the W3C xs:date rules (YYYY-MM-DD).

    Casting Rules

    xs:date format

    Parses the string treating it as an XSD xs:date format.

    Customizable DateTime

    This is a simple but powerful set of rules that allow a date to be parsed.

    The rules are based on the .Net DateTime parser. The parser matches 'Format Specifiers' which can be general rules or specific masks.

    Several Format Specifiers can be provided and the first one to match is used.

    Many of the general format specifies are local specific so ensure the appropriate local is used or use a specific mask to avoid problems on machines in other locals.

    Additional information regarding the format specifiers can be found at

    Custom Regex

    This is the most powerful conversion rule, it allows complex regular expressions to be constructed and value elements extracted into variables that are then used to build the target data type.

    The values required to build the expression are shown under the expression, and a sample expression is initially created.

    The regular expression engine used is the one that ships with .Net 4.0, the rules for regular expressions are complex and beyond the scope of this documentation, but are documented fully elsewhere.