Skip to main content

DTL <subtransform>

Invoke another data transformation.

Syntax

<subtransform class='class-name'
                     targetObj='target-value}'
                     sourceObj='source-value'/>

Attributes

Attribute Description Value
class

Required. Name of the class that contains the data transformation to be invoked. This class must be in the same namespace as the class that invokes it.

Often, class is a DTL data transformation defined using a DTL <transform> element, as shown in the examples in this topic.

Alternatively, class can identify a custom subclass of Ens.DataTransformOpens in a new tab that implements the Transform method and does not use DTL.

The full package and class name.
sourceObject

Required. Identifies the property being transformed. This may be an object property or a virtual document property. Generally it is a property of the source object identified by the containing <transform> element’s sourceClass and (for virtual documents) sourceDocType. In this case it is referenced using dot syntax as follows:

source.property or source.{propertyPath}

Property name. For virtual documents and their segments, use virtual property syntax.
targetObject

Required. Identifies the property into which the transformed value will be written. This may be an object property or a virtual document property. Generally it is a property of the target object identified by the containing <transform> element’s targetClass and (for virtual documents) targetDocType.In this case it is referenced using dot syntax as follows:

target.property or target.{propertyPath}

In the case of a subtransform with Create as new or copy, it is not necessary to have a pre-existing target object.

Property name. For virtual documents and their segments, use virtual property syntax.

Elements

Element Purpose
<annotation> Optional. A text string that describes the <subtransform> element.

Description

The <subtransform> element invokes another data transformation. Making a call to <subtransform> allows the containing <transform> element to invoke other data transformations to complete segments of its work. This allows developers greater flexibility in maintaining a suite of reusable DTL transformation code.

Before the <subtransform> element was available, every DTL <transform> stood alone. In order to write multiple DTL transformations that contained an identical sequence of actions, it was necessary to copy and paste the corresponding sections of code from one class into another. Now, each of these DTL classes can replace repeated lines with a <subtransform> element that invokes another class to performs the desired sequence.

The source or target objects for a <subtransform> may be ordinary InterSystems IRIS objects, virtual document message objects, or virtual document segment objects representing an individual segment within a virtual document message. The <subtransform> is especially important for interface developers working with Electronic Data Interchange (EDI) formats, where each message or document may contain many independent segments that need to be transformed. Having the <subtransform> available means you can create a reusable library of segment transformations that you can call as needed, without duplicating code in the calling transformation.

For virtual documents and their segments, you must use virtual property syntax, such as the {} curly bracket syntax in the following examples. The property path inside the brackets must refer to a particular segment, not to a field within a segment or to a group of segments. For background information, see Using Virtual Documents in Productions; details are available in Virtual Property Path.

FeedbackOpens in a new tab