Your Own Template File
When your ERP system wants its own file layout, give Vitreo a file in that layout. You mark the part that repeats and put tokens where the data goes. Vitreo keeps the shape of your file and fills in the data.
To use your own template file:
- Start from a file your ERP system already imports: XML, JSON or CSV.
- Mark the record that repeats with vitreo-repeat. See below.
- Put a token where the data goes, for example {FileName} or {CP:Material}.
- In the ERP Tools pane, under File, click Template file. Your file is filled and choose the file.
- Check the ERP design and the ERP result.
The names in your file are yours. Vitreo never renames an element, an attribute, a property or a column header.
Mark the record that repeats
Write ONE record the way your ERP system wants it, and add vitreo-repeat to it:
<ListItems count="{Count}">
<ListItem vitreo-repeat="Items">
<PartNo>{FileName}</PartNo>
<Qty>{QtyTotal}</Qty>
</ListItem>
</ListItems>
Vitreo writes that record once per item and removes the marker. Everything outside it is written once.
Your template
<ListItems count="{Count}"> <ListItem vitreo-repeat="Items"> <PartNo>{FileName}</PartNo> <Qty>{QtyTotal}</Qty> </ListItem> </ListItems>
→
What Vitreo writes (3 items)
<ListItems count="3"> <ListItem> <PartNo>A-100</PartNo> <Qty>1</Qty> </ListItem> <ListItem> <PartNo>A-101</PartNo> <Qty>2</Qty> </ListItem> <ListItem> <PartNo>A-102</PartNo> <Qty>4</Qty> </ListItem> </ListItems>
| vitreo-repeat | Writes |
|---|---|
| Items | One record per unique part or assembly. |
| Children | Inside a record: one per component of that item. Nest it as deep as you need. |
| BomLines | One record per parent and child pair. |
| Level0 | One record per level 0 item. |
- XML: the attribute vitreo-repeat="Items" on the element of one record.
- JSON: the property "vitreo-repeat": "Items" on the object inside the array.
- CSV: no marker. Line 1 is the header and is copied. Line 2 is the record with tokens. Later lines are copied. The Records section chooses which records. See Records.
Edit and reload
| Button | What it does |
|---|---|
| Choose template file (folder) | Chooses another template file. |
| Edit template file (pencil) | Opens the file in Notepad. |
| Reload template file (arrows) | Reads the file again and updates the ERP design and the ERP result. |
The same commands are in the right-click menu of the ERP design. ERP export always reads the file again, so your last saved changes are used.
Good to know
- {Count} on the element that holds the repeating record gives the number of those records.
- Vitreo escapes every value, so the file stays valid XML or JSON.
- An XML file keeps the encoding of its first line. A CSV file uses the CSV encoding option.
- The CSV separator is taken from the header line of your file.
- The file name decides the type: .xml, .json, any other file is read as CSV.
- Template > Examples > Save example template files... gives you a working XML, JSON and CSV file.
- The Own file shape? Read how button in the How to use card opens a guide with examples.
When something goes wrong
| Message | What to do |
|---|---|
| No element is marked vitreo-repeat="Items" | Add the marker. Without it, the file is written once, without records. |
| The root element cannot repeat | Put the marker on an element inside the outer element. |
| Unknown repeat | Use Items, Level0, Children or BomLines. |
| repeats Children but sits outside an Items/Level0 record | Move the Children record inside an Items or Level0 record. |
| A CSV template needs a header line and one record line with tokens | Add line 2 with the tokens. |
| The template is not valid XML (or JSON) | Fix the file, then click Reload. |
| Template file not found | Choose the file again with the folder button. |