11# DTL Support
22
3- Starting with version 3.2.0, IoP supports DTL transformations.
3+ Starting with version 3.2.0, IoP supports DTL transformations.
4+
45DTL the Data Transformation Layer in IRIS Interoperability.
6+
57DTL transformations are used to transform data from one format to another with a graphical editor.
68It supports also ` jsonschema ` structures.
79
@@ -94,6 +96,7 @@ Example of payload to test as a source message:
9496Starting with version 3.2.0, IoP supports ` jsonschema ` structures for DTL transformations.
9597
9698Same as for message classes, you need to register your ` jsonschema ` .
99+
97100To do so, you need to invoke his iris command:
98101
99102``` objectscript
@@ -103,4 +106,112 @@ zw ##class(IOP.Message.JSONSchema).ImportFromFile("/irisdev/app/random_jsonschem
103106Where the first argument is the path to the jsonschema file, the second argument is the package name and the third argument is the name of the schema.
104107
105108Then you can use it in your DTL transformation.
106- The schema will be available in the name of ` Demo ` .
109+
110+ The schema will be available in the name of ` Demo ` .
111+
112+ Example ` jsonschema ` file:
113+
114+ ``` json
115+ {
116+ "$schema" : " https://json-schema.org/draft/2020-12/schema" ,
117+ "type" : " object" ,
118+ "title" : " PostMessage" ,
119+ "properties" : {
120+ "post" : {
121+ "allOf" : [
122+ {
123+ "$ref" : " #/$defs/PostClass"
124+ }
125+ ]
126+ },
127+ "to_email_address" : {
128+ "type" : " string" ,
129+ "default" : null
130+ },
131+ "my_list" : {
132+ "type" : " array" ,
133+ "items" : {
134+ "type" : " string"
135+ }
136+ },
137+ "found" : {
138+ "type" : " string" ,
139+ "default" : null
140+ },
141+ "list_of_post" : {
142+ "type" : " array" ,
143+ "items" : {
144+ "allOf" : [
145+ {
146+ "$ref" : " #/$defs/PostClass"
147+ }
148+ ]
149+ }
150+ }
151+ },
152+ "$defs" : {
153+ "PostClass" : {
154+ "type" : " object" ,
155+ "title" : " PostClass" ,
156+ "properties" : {
157+ "title" : {
158+ "type" : " string"
159+ },
160+ "selftext" : {
161+ "type" : " string"
162+ },
163+ "author" : {
164+ "type" : " string"
165+ },
166+ "url" : {
167+ "type" : " string"
168+ },
169+ "created_utc" : {
170+ "type" : " number"
171+ },
172+ "original_json" : {
173+ "type" : " string" ,
174+ "default" : null
175+ }
176+ },
177+ "required" : [
178+ " title" ,
179+ " selftext" ,
180+ " author" ,
181+ " url" ,
182+ " created_utc"
183+ ]
184+ }
185+ }
186+ }
187+ ```
188+
189+ ## Example of DTL Transformation with JsonSchema or Message Class
190+
191+ Many can be found in the ` UnitTest ` package ` ./src/tests/cls ` directory.
192+
193+ ``` objectscript
194+ Class UnitTest.ComplexTransform Extends Ens.DataTransformDTL [ DependsOn = IOP.Message ]
195+ {
196+
197+ Parameter IGNOREMISSINGSOURCE = 1;
198+
199+ Parameter REPORTERRORS = 1;
200+
201+ Parameter TREATEMPTYREPEATINGFIELDASNULL = 0;
202+
203+ XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
204+ {
205+ <transform sourceClass='IOP.Message' targetClass='IOP.Message' sourceDocType='registerFilesIop.message.ComplexMessage' targetDocType='registerFilesIop.message.ComplexMessage' create='new' language='objectscript' >
206+ <assign value='source.{post}' property='target.{post}' action='set' />
207+ <foreach property='source.{list_str()}' key='k1' >
208+ <assign value='source.{list_str(k1)}_"foo"' property='target.{list_str()}' action='append' />
209+ </foreach>
210+ <foreach property='source.{list_post()}' key='k2' >
211+ <assign value='source.{list_post().Title}' property='target.{list_post(k2).Title}' action='append' />
212+ </foreach>
213+ </transform>
214+ }
215+
216+ }
217+ ```
0 commit comments