SuperAPI AI Directory

xdto-compile

General & other

View repository

Updated 10-15 21:03

About this skill

/xdto-compile — Creating an XDTO package from an XML schema

Assembles an XDTO package from an XML schema: XDTOPackages/<Имя>.xml, XDTOPackages/<Имя>/Ext/Package.bin and registration in Configuration.xml.

Input — a regular XML schema; you need to write it the same way as for any other tool.

Parameters

Parameter Required Description
XsdPath one of the two Path to the XML schema file. Alias — -Path
Xsd one of the two Schema as a string, instead of -XsdPath
OutputDir yes Directory of the configuration or extension sources — where Configuration.xml
Name no Metadata object name. By default — from xs:appinfo, otherwise the XSD file name, sanitized for a 1C identifier
Synonym no Synonym (string). By default — from xs:appinfo, otherwise the package name. For multiple languages, specify the synonym in the schema, with the block xs:appinfo
Comment no Comment. By default — from xs:appinfo
Force no Overwrite the existing package. Without it, the skill will refuse to overwrite an already assembled package
powershell.exe -NoProfile -File "${CLAUDE_SKILL_DIR}/scripts/xdto-compile.ps1" -XsdPath "<схема.xsd>" -OutputDir "<каталог-исходников>"

Examples:

... -XsdPath bank.xsd -OutputDir src -Name ОбменСБанком -Synonym "Обмен с банком"
... -XsdPath fss.xsd  -OutputDir src -Force

Read the warnings

XSD is more expressive than the XDTO model. Everything that is not transferred one-to-one, the skill transfers approximately and writes about it:

Предупреждения (2) — конструкции XSD без точного соответствия в модели XDTO:
  ! Документ : вложенная xs:choice уплощена в последовательность — выбор одного из вариантов не сохранён
  ! Документ : кратность на вложенной частице (<xs:sequence minOccurs/maxOccurs>) не выражается в модели XDTO

Such a message means the package was assembled, but the schema was simplified. If the simplification is unacceptable — change the schema (for example, split the variants xs:choice into different types), and do not ignore it.

What is transferred approximately: nested xs:sequence/xs:choice (flattened into a flat list of properties), xs:all (becomes a sequence), multiplicity on a particle, substitutionGroup, xs:key/keyref/unique, xs:redefine.

xs:group и xs:attributeGroup are expanded by reference — their contents end up in the type. xs:include is ignored: dependencies in XDTO are resolved only by namespace, so the included schema must be assembled as a separate package and replace include with import.

See what the result is

The package model lies in Ext/Package.bin. Despite the extension, it is a text XML, but there is usually no need to read it directly: the composition of the assembled package is shown by /xdto-info, and the full schema — by /xdto-decompile.

Dependencies between packages

<xs:import namespace="…"/> is resolved by namespace among configuration or extension packages. If there is no package with such a namespace, the platform at load time will silently substitute the type with xs:anyType — without an error. Assemble dependencies first, then the dependent package, and check the result via /xdto-validate.

Which packages are already assembled can be seen in ChildObjects of the file Configuration.xml.

What XSD cannot express

There are two things the XDTO model can do that XML Schema cannot: nillable for an attribute and qualified for a separate property. They are written as attributes from the model namespace:

<xs:attribute name="Представление" type="xs:string"
              xmlns:xdto="http://v8.1c.ru/8.1/xdto" xdto:nillable="true"/>

The schema remains valid — validators ignore such attributes. The full list and the XSD ↔ XDTO correspondence table — in xsd-reference.md.

Properties of a metadata object can be set directly in the schema:

<xs:annotation>
    <xs:appinfo>
        <xdto:package xmlns:xdto="http://v8.1c.ru/8.1/xdto">
            <xdto:name>ОбменСБанком</xdto:name>
            <xdto:synonym lang="ru">Обмен с банком</xdto:synonym>
        </xdto:package>
    </xs:appinfo>
</xs:annotation>

Typical workflow

  1. Obtain an XSD from the counterparty (or export the schema of an existing package: /xdto-decompile)
  2. /xdto-compile -XsdPath <файл> -OutputDir <каталог-исходников> — read the warnings
  3. /xdto-validate <каталог-исходников>/XDTOPackages/<Имя> — make sure the types have resolved
  4. /db-load-xml + /db-update

Editing an existing package: pointwise — /xdto-edit; rework the schema entirely — /xdto-decompile → edit XSD → /xdto-compile -Force.