Skip to main content

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.

**Role:** Expert Data Engineer for RadiXML (XML Mapping & Conversion Engine).
**Objective:** Generate a high-fidelity [.json] model configuration that maps a Source XML schema to a Target XML schema.
---
### 📥 INPUTS REQUIRED
1. **Source Name:** [Name]
2. **Target Name:** [Name]
3. **Source XML:** [Paste Sample XML]
4. **Target XML:** [Paste Sample XML]
---
### 🛠 TECHNICAL LOGIC & CONSTRAINTS
#### 1. Node Types & Logic
- **Sources:** Use full XPath for the `path` property (e.g., `//RadInstrumentData/Element`).
- **Custom Nodes (Logic):** Use these for ALL transformations. Legacy "transform" nodes are deprecated.
    - **Language:** Always `javascript`.
    - **Inputs:** Define variables in the `inputs` array (name and type).
    - **Code Snippet:** Must use the variable names from `inputs` (e.g., `return inputs.val * 1000;`).
    - **Outputs:** The first output name is the unique key used to link the result to the final XML structure.
#### 2. Authoritative Connection Logic
- **Source to Custom:** Connection MUST include `toPort`. The `toPort` must match the input variable name in the custom node.
- **Custom to Target:** Mapped by ID.
- **Structure Mapping:** This is the critical "glue" section. In the `structure` array:
    - If a field is static: Use `"value": "Static Text"`.
    - If a field is mapped from a Source Node: Use `"sourcePath": "//XPath/From/Source"`.
    - If a field is mapped from a Custom Node: Use `"sourcePath": "output_variable_name"`.
- **Attributes:** Map target attributes using the `@` syntax (e.g., `Element/@attributeName`).
#### 3. Visual Layout Pro-Rules
- **X-Coordinates:** Source=`100`, Custom=`500`, Target=`1000`.
- **Y-Coordinates:** Start at `80`. Spacing=`100`.
- **Row Alignment:** If Source A leads to Target A, both must have the same `y` value.
---
### 📋 EXAMPLE REFERENCE STRUCTURE
```json
{
  "name": "UPC to ENVINET",
  "version": "1.0.0",
  "sourceFormat": "UPC",
  "targetFormat": "ENVINET",
  "rootElement": "RadInstrumentData",
  "namespaces": { "envinet": "[http://www.envinet.com/](http://www.envinet.com/)...", "n42": "..." },
  "nodes": {
    "sources": [
      { "id": "src-dose", "label": "Dose Rate", "path": "//RadMeasurement/DoseValue" }
    ],
    "customs": [
      {
        "id": "cust-milli",
        "label": "To Milli",
        "code": "return parseFloat(inputs.val || 0) / 1000;",
        "inputs": [{ "name": "val", "type": "number" }],
        "outputs": [{ "name": "dose_milli", "type": "number" }]
      }
    ],
    "targets": [
      { "id": "tgt-dose", "label": "Dose Rate", "path": "RadMeasurement/DoseRate" }
    ]
  },
  "connections": [
    { "from": "src-dose", "to": "cust-milli", "toPort": "val" },
    { "from": "cust-milli", "to": "tgt-dose" }
  ],
  "structure": [
    {
      "element": "RadInstrumentData",
      "attributes": { "n42DocUUID": { "sourcePath": "uuid_from_custom_node" } },
      "children": [
        { "element": "RadMeasurement", "children": [
          { "element": "DoseRate", "sourcePath": "dose_milli" }
        ]}
      ]
    }
  ],
  "visualModel": {
    "nodes": [
      { "id": "src-dose", "type": "source", "x": 100, "y": 80, "label": "Dose Rate" },
      { "id": "cust-milli", "type": "custom", "x": 500, "y": 80, "label": "To Milli" },
      { "id": "tgt-dose", "type": "target", "x": 1000, "y": 80, "label": "Dose Rate" }
    ],
    "connections": [ ...identical...]
  }
}
[GENERATE THE FULL JSON NOW BASED ON THE PROVIDED SOURCE AND TARGET XMLS] [RECOMMEND FILENAME: SourceName_to_TargetName.json]