Cast type (xs:type)

You can use an xs:type transform to cast the value of a simple element to a specific data type.

Overview

For example, you might want to assign a value with a specific data type to a target element that is defined as xs:anySimpleType.

When you use an xs:type transform, you can have zero or more input elements mapped to the transform, but only a single output element. You can cast one value to set the output element. This value is set in the Value column of the General tab on the Properties page. The value can be one of the following entities:
  • A literal value
  • A single input value
  • An XPath expression that uses zero or more of the input values

You can also use any of the input elements to build an XPath conditional expression that determines whether the xs:type transform is applied or not. You set this conditional expression on the Condition tab of the Properties page.

You must choose the xs:type transform according to the output element data type. For example, if you have an output element with a Boolean data type, you must choose xs:boolean transform.

For more information about casting a specific value type to an output element, see Setting the value of an output element with a explicit data type.

Assign a value

You can set a fixed value or define an XPath expression in the Value field that is located in the General tab of a xs:type transform properties view.

This figure shows the general tab in the Properties view for the Assign transform.

To define an XPath expression, you click Edit. Then, you can use content-assist to enter the expression. As part of the expression, you can use any input elements for which you define connections to the transform.

Define when the transform is applied at run time

You can define multiple connections between input elements and the xs:type transform. You can then use these input elements in a conditional expression that defines the condition under which the transform is applied. If the condition evaluates to true, the transform is applied.

To define the conditional expression, you can define an XPath expression or a call to a static method on an imported Java™ class. You can also create a complex expression comprising XPath, Java and extension functions such as iib:getUserDefinedProperty("propertyname").  

You configure the expression in the Condition tab that is available in the Properties page of the transform.

For more information, see Configuring the properties of a transform, Defining an XPath conditional expression for a transform and Defining a Java conditional expression for a transform.

When you define multiple input connections, you can configure the following properties to define how those inputs are displayed in the message map:
  • Sort: You can sort the inputs to the transform by ascending order, descending order, case order, or data order.
  • Order: You can display the order of input connections to a transform. You can reorder them.

You can use the input connected with a primary connection to the transform. To add more inputs, you can define supplement connections between input elements and the transform.

Note: You only can sort and order inputs that are connected with a primary connection to the transform.

xs:type transforms

You can use any of the following xs:any transforms:
  • xs:NOTATION: This function takes a primitive and casts it as notation.
  • xs:Qname: This function takes a primitive and casts it as a qualified name.
  • xs:anyURI: This function takes a primitive and casts it as anyURI.
  • xs:base64Binary: This function takes a primitive and casts it as base64Binary.
  • xs:boolean: This function takes a primitive and casts it as boolean.

    You can use any of the following values: true Or false.

  • xs:dateTime: This function takes a primitive and casts it as dateTime.
  • xs:date: This function takes a primitive and casts it as date.
  • xs:dayTimeDuration: This function takes a primitive and casts it as dayTimeduration.
  • xs:decimal: This function takes a primitive and casts it as decimal.
  • xs:double: This function takes a primitive and casts it as double.
  • xs:float: This function takes a primitive and casts it as float.
  • xs:gDay: This function takes a primitive and casts it as gDay.
  • xs:gMonthDay: This function takes a primitive and casts it as gMonthDay.
  • xs:gMonth: This function takes a primitive and casts it as gMonth.
  • xs:gYearMonth: This function takes a primitive and casts it as gYearMonth.
  • xs:gYear: This function takes a primitive and casts it as gYear.
  • xs:hexBinary: This function takes a primitive and casts it as hexBinary.
  • xs:integer: This function takes a primitive and casts it as integer.
  • xs:int: This function takes a primitive and casts it as signed 32-bit integer.
  • xs:string: This function takes a primitive and casts it as string.
  • xs:time: This function takes a primitive and casts it as time.
  • xs:yearMonthDuration: This function takes a primitive and casts it as yearMonthDuration.

For more information, see Casting from primitive types to primitive types.