Skip to content

Commit 5680d85

Browse files
akoclaude
andcommitted
feat: add Data Transformer support (JSLT/XSLT, Mendix 11.9+)
Adds full MDL support for the new DataTransformers$DataTransformer document type introduced in Mendix 11.9. Transformers define JSON-to- JSON (or XML) transformation pipelines using JSLT expressions. Syntax: CREATE DATA TRANSFORMER Module.Name SOURCE JSON '{"input": "data"}' { JSLT $$ { "output": .input } $$; }; LIST DATA TRANSFORMERS [IN Module]; DESCRIBE DATA TRANSFORMER Module.Name; DROP DATA TRANSFORMER Module.Name; Steps use technology keywords (JSLT, XSLT) directly — no STEP label. Single-line expressions use '...', multi-line use $$ ... $$ quoting (same as Java actions). DESCRIBE auto-selects the right format based on whether the expression contains newlines. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f984d17 commit 5680d85

29 files changed

Lines changed: 12725 additions & 11259 deletions

cmd/mxcli/help_topics/rest.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,34 @@ CATALOG QUERIES
162162
-- Published API surface area
163163
SELECT ServiceQualifiedName, ResourceName, HttpMethod, Path, Microflow
164164
FROM CATALOG.PUBLISHED_REST_OPERATIONS;
165+
166+
DATA TRANSFORMERS
167+
-----------------
168+
169+
LIST DATA TRANSFORMERS; -- List all transformers
170+
LIST DATA TRANSFORMERS IN MyModule; -- Filter by module
171+
DESCRIBE DATA TRANSFORMER MyModule.WeatherTransform; -- Re-executable CREATE
172+
173+
-- Single-line JSLT step
174+
CREATE DATA TRANSFORMER MyModule.Flatten
175+
SOURCE JSON '{"a": {"b": 1}}'
176+
{
177+
JSLT '{"value": .a.b}';
178+
};
179+
180+
-- Multi-line JSLT step using $$ quoting
181+
CREATE DATA TRANSFORMER MyModule.WeatherTransform
182+
SOURCE JSON '{"latitude": 51.9, "current": {"temp": 12.8}}'
183+
{
184+
JSLT $$
185+
{
186+
"lat": .latitude,
187+
"temp": .current.temp
188+
}
189+
$$;
190+
};
191+
192+
DROP DATA TRANSFORMER MyModule.WeatherTransform; -- Delete transformer
193+
194+
Requires Mendix 11.9+. Steps: JSLT, XSLT.
195+
Single-line: JSLT '...'. Multi-line: JSLT $$ ... $$.

cmd/mxcli/lsp_completions_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs-site/src/examples/rest-integration.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,51 @@ CREATE OR REPLACE PUBLISHED REST SERVICE Module.OrderAPI (
298298
-- Remove entirely
299299
DROP PUBLISHED REST SERVICE Module.OrderAPI;
300300
```
301+
302+
## Data Transformers (JSLT)
303+
304+
Data Transformers apply transformation steps (JSLT or XSLT) to JSON or XML payloads. Useful for reshaping API responses before import mapping, or normalising data from third-party sources. Requires Mendix 11.9+.
305+
306+
```sql
307+
-- Create a transformer that extracts key fields from a weather API response.
308+
-- The SOURCE JSON defines a sample payload used for schema inference and testing.
309+
CREATE DATA TRANSFORMER Integration.WeatherTransform
310+
SOURCE JSON '{
311+
"latitude": 51.9,
312+
"longitude": 4.5,
313+
"timezone": "Europe/Amsterdam",
314+
"current": {
315+
"time": "2024-01-15T14:00",
316+
"temperature_2m": 12.8,
317+
"wind_speed_10m": 18.3,
318+
"weather_code": 3
319+
}
320+
}'
321+
{
322+
JSLT $$
323+
{
324+
"lat": .latitude,
325+
"lon": .longitude,
326+
"timezone": .timezone,
327+
"temp": .current.temperature_2m,
328+
"wind_speed": .current.wind_speed_10m,
329+
"code": .current.weather_code
330+
}
331+
$$;
332+
};
333+
334+
-- List all data transformers in the Integration module
335+
LIST DATA TRANSFORMERS IN Integration;
336+
337+
-- Inspect a transformer (outputs a re-executable CREATE statement)
338+
DESCRIBE DATA TRANSFORMER Integration.WeatherTransform;
339+
340+
-- Remove a transformer
341+
DROP DATA TRANSFORMER Integration.WeatherTransform;
342+
```
343+
344+
**Notes:**
345+
- Steps execute in order; the output of each step feeds the next.
346+
- `JSLT '...'` for short single-line expressions; `JSLT $$ ... $$` for multi-line.
347+
- `XSLT $$ ... $$` is also supported for XML-to-XML transformations.
348+
- Requires Mendix 11.9+. Use `SHOW FEATURES` to confirm support before using.

docs/01-project/MDL_QUICK_REFERENCE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,30 @@ CREATE PUBLISHED REST SERVICE Module.MyAPI (
527527
**Path parameters:** Must match a microflow parameter exactly (case-sensitive). E.g., `'{id}'` requires the microflow to have parameter `$id`.
528528
**Operation modifiers:** `DEPRECATED`, `IMPORT MAPPING Module.Name`, `EXPORT MAPPING Module.Name`, `COMMIT Yes|No`
529529

530+
## Data Transformers
531+
532+
Requires Mendix 11.9+. Steps: `JSLT`, `XSLT`. Single-line: `JSLT '...'`. Multi-line: `JSLT $$ ... $$`.
533+
534+
| Statement | Syntax | Notes |
535+
|-----------|--------|-------|
536+
| List transformers | `LIST DATA TRANSFORMERS [IN Module];` | |
537+
| Describe transformer | `DESCRIBE DATA TRANSFORMER Module.Name;` | Re-executable CREATE |
538+
| Create transformer | See syntax below | |
539+
| Drop transformer | `DROP DATA TRANSFORMER Module.Name;` | |
540+
541+
```sql
542+
CREATE DATA TRANSFORMER Module.WeatherTransform
543+
SOURCE JSON '{"latitude": 51.9, "current": {"temp": 12.8}}'
544+
{
545+
JSLT $$
546+
{
547+
"lat": .latitude,
548+
"temp": .current.temp
549+
}
550+
$$;
551+
};
552+
```
553+
530554
## JSON Structures
531555

532556
| Statement | Syntax | Notes |
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
-- ============================================================================
2+
-- Data Transformer Examples
3+
-- ============================================================================
4+
--
5+
-- Demonstrates creating, describing, listing, and dropping data transformers.
6+
--
7+
-- Prerequisites:
8+
-- - Mendix 11.9+ (Data Transformers require >= 11.9)
9+
--
10+
-- ============================================================================
11+
12+
CREATE MODULE DtTest;
13+
14+
-- ############################################################################
15+
-- PART 1: SIMPLE SINGLE-LINE JSLT TRANSFORMER
16+
-- ############################################################################
17+
18+
-- Flatten a nested JSON object using a single-line JSLT expression.
19+
CREATE DATA TRANSFORMER DtTest.FlattenNested
20+
SOURCE JSON '{"wrapper": {"value": 42, "label": "hello"}}'
21+
{
22+
JSLT '{"value": .wrapper.value, "label": .wrapper.label}';
23+
};
24+
25+
-- ############################################################################
26+
-- PART 2: MULTI-LINE JSLT TRANSFORMER WITH $$ QUOTING
27+
-- ############################################################################
28+
29+
-- Extract key fields from a weather API response using a multi-line JSLT step.
30+
CREATE DATA TRANSFORMER DtTest.WeatherTransform
31+
SOURCE JSON '{"latitude": 51.9, "longitude": 4.5, "timezone": "Europe/Amsterdam", "current": {"time": "2024-01-15T14:00", "temperature_2m": 12.8, "wind_speed_10m": 18.3, "weather_code": 3}}'
32+
{
33+
JSLT $$
34+
{
35+
"lat": .latitude,
36+
"lon": .longitude,
37+
"timezone": .timezone,
38+
"temp": .current.temperature_2m,
39+
"wind_speed": .current.wind_speed_10m,
40+
"code": .current.weather_code
41+
}
42+
$$;
43+
};
44+
45+
-- ############################################################################
46+
-- PART 3: LIST AND DESCRIBE
47+
-- ############################################################################
48+
49+
-- List all data transformers in the project
50+
LIST DATA TRANSFORMERS;
51+
52+
-- List data transformers in a specific module
53+
LIST DATA TRANSFORMERS IN DtTest;
54+
55+
-- Describe a transformer (outputs a re-executable CREATE statement)
56+
DESCRIBE DATA TRANSFORMER DtTest.WeatherTransform;
57+
58+
-- ############################################################################
59+
-- PART 4: DROP
60+
-- ############################################################################
61+
62+
DROP DATA TRANSFORMER DtTest.FlattenNested;
63+
DROP DATA TRANSFORMER DtTest.WeatherTransform;

mdl/ast/ast_datatransformer.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package ast
4+
5+
// CreateDataTransformerStmt represents:
6+
//
7+
// CREATE DATA TRANSFORMER Module.Name SOURCE JSON '...' { JSLT '...'; };
8+
type CreateDataTransformerStmt struct {
9+
Name QualifiedName
10+
SourceType string // "JSON" or "XML"
11+
SourceJSON string // the source content
12+
Steps []DataTransformerStepDef
13+
}
14+
15+
func (s *CreateDataTransformerStmt) isStatement() {}
16+
17+
// DataTransformerStepDef represents a single step: JSLT '...' or XSLT '...'
18+
type DataTransformerStepDef struct {
19+
Technology string // "JSLT", "XSLT"
20+
Expression string
21+
}
22+
23+
// DropDataTransformerStmt represents: DROP DATA TRANSFORMER Module.Name
24+
type DropDataTransformerStmt struct {
25+
Name QualifiedName
26+
}
27+
28+
func (s *DropDataTransformerStmt) isStatement() {}

mdl/ast/ast_query.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const (
7979
ShowImageCollections // SHOW IMAGE COLLECTIONS [IN module]
8080
ShowRestClients // SHOW REST CLIENTS [IN module]
8181
ShowPublishedRestServices // SHOW PUBLISHED REST SERVICES [IN module]
82+
ShowDataTransformers // LIST DATA TRANSFORMERS [IN module]
8283
ShowConstantValues // SHOW CONSTANT VALUES [IN module]
8384
ShowContractEntities // SHOW CONTRACT ENTITIES FROM Module.Service
8485
ShowContractActions // SHOW CONTRACT ACTIONS FROM Module.Service
@@ -193,6 +194,8 @@ func (t ShowObjectType) String() string {
193194
return "REST CLIENTS"
194195
case ShowPublishedRestServices:
195196
return "PUBLISHED REST SERVICES"
197+
case ShowDataTransformers:
198+
return "DATA TRANSFORMERS"
196199
case ShowConstantValues:
197200
return "CONSTANT VALUES"
198201
case ShowContractEntities:
@@ -280,6 +283,7 @@ const (
280283
DescribeImageCollection // DESCRIBE IMAGE COLLECTION Module.Name
281284
DescribeRestClient // DESCRIBE REST CLIENT Module.Name
282285
DescribePublishedRestService // DESCRIBE PUBLISHED REST SERVICE Module.Name
286+
DescribeDataTransformer // DESCRIBE DATA TRANSFORMER Module.Name
283287
DescribeContractEntity // DESCRIBE CONTRACT ENTITY Service.EntityName [FORMAT mdl]
284288
DescribeContractAction // DESCRIBE CONTRACT ACTION Service.ActionName [FORMAT mdl]
285289
DescribeContractMessage // DESCRIBE CONTRACT MESSAGE Service.MessageName
@@ -344,6 +348,8 @@ func (t DescribeObjectType) String() string {
344348
return "REST CLIENT"
345349
case DescribePublishedRestService:
346350
return "PUBLISHED REST SERVICE"
351+
case DescribeDataTransformer:
352+
return "DATA TRANSFORMER"
347353
case DescribeContractEntity:
348354
return "CONTRACT ENTITY"
349355
case DescribeContractAction:

0 commit comments

Comments
 (0)