SuperAPI AI Directory

mxl-compile

General & other

View repository

Updated 10-15 21:04

About this skill

/mxl-compile — Template compiler from DSL

Accepts a compact JSON definition of the template (areas, parameters, styles) → generates Template.xml of a 1C spreadsheet document: palettes, indices, merges, namespace.

Usage

/mxl-compile <JsonPath> <OutputPath>

Parameters

Parameter Required Description
JsonPath yes Path to the JSON definition of the template
OutputPath yes Path for generating Template.xml

Command

powershell.exe -NoProfile -File "${CLAUDE_SKILL_DIR}/scripts/mxl-compile.ps1" -JsonPath "<путь>.json" -OutputPath "<путь>/Template.xml"

Workflow

  1. Write a JSON definition (Write tool) → file .json
  2. Call /mxl-compile to generate Template.xml
  3. Call /mxl-validate to check correctness
  4. Call /mxl-info to verify the structure

If the template is created from an image (screenshot, scan of a print form) — first call /img-grid to overlay a grid, use it to determine column boundaries and proportions, then use "Nx" widths + "page" for automatic calculation of dimensions.

What to read for the task

Below is everything needed for a typical template. The rest is stored one file per task; you need to read only your own:

Task Keys File
Style property outside the common ones: indent, protection, pattern, mask, behavior on output — reference/style-properties.md
An area not described by a row range; its own column widths for part of the document namedAreas, columnSets, columnSet reference/layout.md
Headers and footers, orientation, margins, scale header, footer, printSettings reference/print.md
Picture, shape, or text over the grid; picture in a cell pictures, drawings, pictureParameter reference/drawings.md
Cells for user data entry valueType, controlType, value reference/input-cells.md
Collapsible groups of rows or columns rowGroups, columnGroups reference/groups.md
Tooltip for a cell note reference/notes.md

Example

{
  "columns": 5,
  "columnWidths": { "1": 5, "2": 40, "3-5": 12 },
  "fonts": { "жирный": { "face": "Arial", "size": 10, "bold": true } },
  "styles": {
    "шапка":  { "font": "жирный", "horizontalAlignment": "Center", "textPlacement": "Wrap", "border": "Solid" },
    "клетка": { "border": "Solid" },
    "число":  { "border": "Solid", "horizontalAlignment": "Right", "format": "ЧЦ=15; ЧДЦ=2" },
    "итог":   { "font": "жирный", "horizontalAlignment": "Right", "topBorder": "Solid" }
  },
  "areas": [
    { "name": "Заголовок", "rows": [
      { "height": 20, "cells": [{ "col": 1, "span": 5, "style": "шапка", "param": "ЗаголовокОтчёта" }] },
      {}
    ]},
    { "name": "ШапкаТаблицы", "rows": [
      { "rowStyle": "шапка", "cells": ["№", "Номенклатура", "Количество", "Цена", "Сумма"] }
    ]},
    { "name": "Строка", "rows": [
      { "rowStyle": "клетка", "cells": [
        { "col": 1, "param": "НомерСтроки" },
        { "col": 2, "param": "Товар", "detail": "Номенклатура" },
        { "col": 3, "style": "число", "param": "Количество" },
        { "col": 4, "style": "число", "param": "Цена" },
        { "col": 5, "style": "число", "param": "Сумма" }
      ]}
    ]},
    { "name": "Итого", "rows": [
      { "rowStyle": "итог", "cells": [null, null, null, "Итого:", "{Всего}"] }
    ]}
  ]
}

The table header and total are written positionally — the position is taken from the order, col is not needed; the table row is written as cells with col, because they have different styles and decoding.

DSL structure

{ columns, page, defaultWidth, columnWidths, columnStyles, textLanguages,
  fonts:  { имя: { face, size, bold, italic, underline, strikeout } | { ref } },
  styles: { имя: { font, horizontalAlignment, verticalAlignment, textPlacement,
                   border, leftBorder, topBorder, rightBorder, bottomBorder,
                   borderColor, backColor, textColor, format } },
  areas: [{ name, columnSet, rows: [
    { height, hidden, rowStyle, empty, cells: [
      { col, span, rowspan, style, param, detail, text, template, note,
        valueType, controlType, value, pictureParameter } ] } ] }],
  namedAreas, columnSets, rowGroups, columnGroups, header, footer, printSettings,
  pictures, drawings
}

Top level: columns is required, the rest as needed.

Key Description
columns Default number of layout columns
page Page format: "A4-landscape" (780), "A4-portrait" (540) or a number. It computes defaultWidth from the sum of proportions "Nx"
defaultWidth Default column width (10)
columnWidths Widths: 1-based keys ("1", "3-14", "5,7,9"), value — a number or "2x" (fraction of defaultWidth)
columnStyles Style for an entire column: the same range keys, value — style name
textLanguages Languages into which text specified as a string is expanded (by default ["ru"])
areas Areas — ranges of consecutive rows, in document order

Areas, rows, cells

Area (areas[]) — a range of consecutive rows: name (optional; with a name the area is available as Макет.ПолучитьОбласть("Имя")) и rows. An unnamed area is just a piece of the grid.

Row (rows[]): height, hidden, rowStyle, cells. An empty string — {}, а { "empty": 3 } replaces three in a row. height и hidden — properties of the row itself; a cell has no such properties.

Cell (cells[]):

Key Description
col Column position, 1-based
span / rowspan Merge right / down
style Style name; overrides rowStyle for this cell
param Fill parameter — Область.Параметры.Имя = …
text Static text: a string or an object "language → text"
template Text with insertions [Параметр]
detail Decryption parameter; is set even without param

Content is specified by exactly one key from param / text / template; a cell without them is empty (needed, for example, for a border). An empty string "text": "" is also text, not the absence of text.

Short form: a list of cells positionally

The position is taken from the order, col is not needed:

Element Value
"текст" Static text
{ "ru": "…", "en": "…" } The same text in several languages
"{Имя}" Fill parameter
">" Continuation of the cell on the left — increases its span
`" "`
null Skip column
{ … } Regular cell without col — when needed style, detail, template
"rows": [
  ["Вид", "Остаток", ">", "Итог"],
  ["|",   "начало",  "конец", "|"],
  ["{Вид}", "{Нач}", "{Кон}", "{Итог}"]
]

Here “View” and “Total” are merged vertically, “Remainder” — horizontally across two columns.

A positional list is a form of writing CELLS, not a row. If a row has no properties of its own, it is the row (as in the example above). If needed height, hidden or rowStyle — the same list is placed in cells:

{ "rowStyle": "итог", "cells": [null, null, null, "Итого:", "{Всего}"] }

rowStyle — row formatting

The style applies to the ENTIRE width of the row: columns without explicit cells also receive it — this is how solid borders are produced in the tabular section. It also becomes the formatting of the row itself. Cells with rowspan from previous rows are skipped.

Formatting

A cell, row, and column reference the same named style: the cell — with the key style, the row — rowStyle, the column — via columnStyles.

Font (fonts.<имя>): face (Arial), size (10), bold, italic, underline, strikeout. Or a reference instead of a description: { "ref": "style:TextFont" }, { "ref": "sys:DefaultGUIFont" }. Font "default" is taken when the style did not specify its own.

Common style keys — the key name matches the property name in the export, enumeration values are case-insensitive:

Key Value
font Name from fonts
horizontalAlignment Left, Center, Right, Justify, Auto
verticalAlignment Top, Center, Bottom
textPlacement Long text: Wrap (wrap), Cut (truncate), Block, Auto
border Border on all sides
leftBorder, topBorder, rightBorder, bottomBorder Individual side
borderColor Border color
backColor, textColor Background and text color
format 1C data format: "ЧЦ=15; ЧДЦ=2", "ДФ=dd.MM.yyyy"

Border: "Solid" (width 1) or { "style": "Solid", "width": 2 }. Line styles: None, Solid, Dotted, Dashed, DashDotted, DashDottedDotted, ThinDashed, LargeDashed, ThickDashed, Double. Sides can always be specified individually: the compiler will collapse matching four itself.

Color — platform notation: #RRGGBB, style:ИмяСтиля (configuration style item), web:Имя, win:Имя. A nonexistent name will be rejected by the platform on load.

"styles": {
  "шапка":  { "font": "жирный", "horizontalAlignment": "Center", "backColor": "#EBEBEB" },
  "рамка":  { "border": { "style": "Solid", "width": 2 } },
  "снизу":  { "bottomBorder": "Dotted" }
}