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.
TASK: Generate a RadiXML Model JSON
You are an expert XML integration engineer. Your task is to generate a `model.json` file for the RadiXML converter system.
1. Context Information**Context**:
- **Source Format Name**:Format: [INSERT_SOURCE_NAME]SOURCE_NAME]
- **Target Format Name**:Format: [INSERT_TARGET_NAME]TARGET_NAME]
- **Sample Source XML**:
[INSERT_SOURCE_SAMPLE]
- **Sample Target XML**:Filename: [INSERT_TARGET_SAMPLE]
2. Requirements
- Create a single JSON object.
- **Root attributes**: Include `name`, `description`, `sourceFormat`, `targetFormat`, `rootElement`, and `namespaces`.
- **Logic Rule**: Use ONLY **JavaScript Custom Nodes** for any data transformation or calculation. Do NOT use `transform` nodes.
- **Connection Rule**: Every dynamic value must flow from a `Source Node` -> `Custom Node` -> `Target Node`.
- **Static Values**: Use `staticValue` in the Target Node or `value` in the `structure` for fields that never change.
3. Custom Node Implementation Guide
A custom node mustMust be structuredexactly as follows:
- Unique string`[Source]To[Target].json` (e.g., `UPCtoENVINET.json`)
- Input Sample: [SOURCE_XML]
- Output Goal: [TARGET_XML]
2. **General Data**:
- `name`: "custom-1234"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).
- `language`id`: "javascript".Unique string.
- `label`: Name for the UI.
- `inputs`: DefinesArray variableof names`{ name, type }` (e.g., `DoseRateIn`{ "name": "val", "type": "number" }`).
- `outputs`: DefinesArray the result name (e.g.,of `DoseRateOut`){ name, type }`.
- `code`: MustValid beJS string with a valid JS function. Example:
`function run() { //... Inputs}`.
are- accessible directly by name
const val = parseFloat(DoseRateIn);
return`color`: (valOptional) UI color (e.g., "#04ff00").
- **targets**: 1000).toFixed(2);Define }paths where data will be stored.
- Can have `staticValue` for hardcoded defaults.
- Can have `attributes` map.
4. Model**Connections Anatomy(`connections`)**:
Reference- 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 this`element`, structure`attributes`, as`value`, your`sourcePath` template:(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": "FormatENVINET Converter"to UPC Converted",
"sourceFormat": "ENVINET",
"targetFormat": "UPC",
"rootElement": "RadInstrumentData",
"namespaces": { "ns"envinet": "...", "n42": "..." },
"nodes": {
"sources": [ { "id": "src-1"s1", "label": "Value"Dose", "path": "Path/To/Tag"DosePath" } ],
"targets": [ { "id": "tgt-1", "label": "Result", "path": "Result/Path" } ],
"customs": [ {
"id": "custom-1"c1", "label": "Conv", "language": "javascript", "color": "#04ff00",
"inputs": [{"name": "In", "type": "number"}],
"outputs": [{"name": "Out", "type": "number"}],
"code": "function run() { return (parseFloat(In) * 1000)...toFixed(2); }"
}],
"targets": [{ "id": "t1", "label": "Res", "path": "ResPath" }]
},
"connections": [
{ "from": "src-1"s1", "to": "custom-1"c1" }, { "from": "custom-1"c1", "to": "tgt-1"t1" }
],
"structure": [
{ "element": "Parent"Measurement", "children": [
{ "element": "Child"Value", "value": "" }] //}],
Targeted"visualModel": by{
connections"nodes": [
{ "id": "s1", "type": "source", "label": "Dose", "x": 100, "y": 80 },
{ "id": "c1", "type": "custom", "label": "Conv", "x": 450, "y": 200 },
{ "id": "t1", "type": "target", "label": "Res", "x": 900, "y": 80 }
],
"connections": [{ "from": "s1", "to": "c1" }, { "from": "c1", "to": "t1" }]
}
]
}
5. Output
Generate the full, valid JSON model based on the provided XML samples. Name will be "{Source}to{Target}.json" Ensure every mandatory tag in the Target XML is present in the `structure`.