Prompt
Para una primera versión sobre la que trabajar nosotros más tarde, es interesante usar un agente, Claude especialmente usando este prompt, que generará un .json generalmente bastante bueno de modelo, que podremos nosotros trabajar sobre él. Reemplazar [SOURCE_NAME], [TARGET_NAME], [SOURCE_XML] y [TARGET_XML] por los nombres y los samples que correspondan a los XMLs de origen y destino.
TASK: Generate a RadiXML Model JSON
1. **Context**:
- Source Format: [SOURCE_NAME]
- Target Format: [TARGET_NAME]
- Target Filename: Must be exactly `[Source]To[Target].json` (e.g., `UPCtoENVINET.json`)
- Input Sample: [SOURCE_XML]
- Output Goal: [TARGET_XML]
2. **General Data**:
- `name`: "Descriptive name"
- `version`: "1.0.0"
- `rootElement`: The root tag of the output XML.
- `namespaces`: Map of prefixes to URIs.
3. **Logical Nodes (`nodes`)**:
- **sources**: Define paths to extract data from source XML.
- **customs**: JavaScript logic nodes ONLY (no transform nodes).
- `id`: Unique string.
- `label`: Name for the UI.
- `inputs`: Array of `{ name, type }` (e.g., `{ "name": "val", "type": "number" }`).
- `outputs`: Array of `{ name, type }`.
- `code`: Valid JS string with a `function run() { ... }`.
- `color`: (Optional) UI color (e.g., "#04ff00").
- **targets**: Define paths where data will be stored.
- Can have `staticValue` for hardcoded defaults.
- Can have `attributes` map.
4. **Connections (`connections`)**:
- Map from node ID to node ID.
- Flows should be: `Source -> Custom -> Target` or `Source -> Target`.
5. **Document Structure (`structure`)**:
- Define the recursive tree for the target XML.
- Use `element`, `attributes`, `value`, `sourcePath` (for direct source mapping), and `children`.
- **Note**: Connections to targets override `value` and `sourcePath`.
6. **Visual Model (`visualModel`) - [REQUIRED FOR EDITOR]**:
- **nodes**: Array of `{ id, type, label, x, y }`.
- `type` is "source", "target", or "custom".
- **Layout Rules**:
- **Sources (Left)**: x=100. Vertical spacing: y increments of 60.
- **Targets (Right)**: x=900. Vertical spacing: y increments of 60.
- **Customs (Center)**: x=450. Vertical spacing: y increments of 200 (Separated).
- **connections**: Exactly match the logical `connections` array.
7. **Structural Constraint (CRITICAL)**:
The JSON root must be flat. `connections`, `nodes`, `structure`, and `visualModel` must all be children of the root object.
8. **Sample Correct Structure**:
{
"name": "Test to Test Corrected",
"description": "Simplified test model with logic in both logical and visual nodes",
"sourceFormat": "Test",
"targetFormat": "Test",
"rootElement": "Device",
"namespaces": {},
"nodes": {
"sources": [
{
"id": "src-name",
"label": "Device Name",
"path": "Name"
},
{
"id": "src-value",
"label": "Raw Value",
"path": "Value"
}
],
"customs": [
{
"id": "custom-double",
"label": "Double Value",
"language": "javascript",
"color": "#a78bfa",
"inputs": [
{
"name": "val",
"type": "number"
}
],
"outputs": [
{
"name": "res",
"type": "number"
}
],
"code": "function run() {\n return (parseFloat(val) * 2).toString();\n}"
}
],
"targets": [
{
"id": "tgt-name",
"label": "Device Label",
"path": "Device/Label"
},
{
"id": "tgt-result",
"label": "Processed Result",
"path": "Device/Result"
}
]
},
"connections": [
{
"from": "src-name",
"to": "tgt-name"
},
{
"from": "src-value",
"to": "custom-double"
},
{
"from": "custom-double",
"to": "tgt-result"
}
],
"structure": [
{
"element": "Device",
"children": [
{
"element": "Label",
"value": ""
},
{
"element": "Result",
"value": ""
}
]
}
],
"visualModel": {
"nodes": [
{
"id": "src-name",
"type": "source",
"label": "Device Name",
"x": 100,
"y": 80
},
{
"id": "src-value",
"type": "source",
"label": "Raw Value",
"x": 100,
"y": 140
},
{
"id": "custom-double",
"type": "custom",
"label": "Double Value",
"x": 450,
"y": 200,
"color": "#a78bfa",
"language": "javascript",
"inputs": [
{
"name": "val",
"type": "number"
}
],
"outputs": [
{
"name": "res",
"type": "number"
}
],
"code": "function run() {\n return (parseFloat(val) * 2).toString();\n}"
},
{
"id": "tgt-name",
"type": "target",
"label": "Device Label",
"x": 900,
"y": 80
},
{
"id": "tgt-result",
"type": "target",
"label": "Processed Result",
"x": 900,
"y": 140
}
],
"connections": [
{
"from": "src-name",
"to": "tgt-name"
},
{
"from": "src-value",
"to": "custom-double"
},
{
"from": "custom-double",
"to": "tgt-result"
}
]
}
}