feat(meta-compile,meta-decompile): кастомизация стандартных реквизитов — FillValue/ChoiceParameterLinks/… (v1.27/v0.18)

Внутри StandardAttributes стандартные реквизиты кастомизируются теми же
свойствами, что и обычные — профиль их не захватывал. Расширен override:
fillValue (DTR-путь/строка/bool через Normalize-ChoiceValue, дефолт nil),
choiceParameterLinks/choiceParameters (переиспользованы эмиттеры реквизита с
xr:-тегом; dataPath — self-резолв Ссылка→StandardAttribute.Ref), comment,
mask, choiceForm. Декомпилятор: парсинг вынесен в Parse-ChoiceParameter*
(namespace-параметр md:/xr:), захват в override.

Закрыто на выборке: ChoiceParameterLinks/Parameters/Comment/Mask=0;
FillValue — DTR-путь(863)/empty-string(150)/bool(21)/string(4). Регресс 45/45
ps1+py, ps1↔py identical. spec §7.1.1, кейс catalog-stdattr-custom.

NOT COVERED (вырожденные, редкие): fillValue стандартного реквизита как
xs:string из пробелов (119, теряется при PreserveWhitespace=false) и пустой
xr:DesignTimeRef (49).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-07-04 13:12:52 +03:00
co-authored by Claude Opus 4.8
parent 8b01d7a6bd
commit e95fb6b619
10 changed files with 772 additions and 71 deletions
@@ -1,4 +1,4 @@
# meta-compile v1.26 — Compile 1C metadata object from JSON
# meta-compile v1.27 — Compile 1C metadata object from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory)]
@@ -1045,6 +1045,9 @@ function Emit-StandardAttribute {
$fts = OvOr 'FullTextSearch' 'Use'
$syn = OvOr 'Synonym' ''
$tt = OvOr 'ToolTip' ''
$cf = OvOr 'ChoiceForm' ''
$cmt = OvOr 'Comment' ''
$msk = OvOr 'Mask' ''
X "$indent<xr:StandardAttribute name=`"$attrName`">"
X "$indent`t<xr:LinkByType/>"
X "$indent`t<xr:FillChecking>$fc</xr:FillChecking>"
@@ -1055,7 +1058,7 @@ function Emit-StandardAttribute {
Emit-MLText "$indent`t" "xr:ToolTip" $tt
X "$indent`t<xr:ExtendedEdit>false</xr:ExtendedEdit>"
X "$indent`t<xr:Format/>"
X "$indent`t<xr:ChoiceForm/>"
if ($cf) { X "$indent`t<xr:ChoiceForm>$(Esc-Xml "$cf")</xr:ChoiceForm>" } else { X "$indent`t<xr:ChoiceForm/>" }
X "$indent`t<xr:QuickChoice>Auto</xr:QuickChoice>"
X "$indent`t<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>"
X "$indent`t<xr:EditFormat/>"
@@ -1064,12 +1067,19 @@ function Emit-StandardAttribute {
X "$indent`t<xr:MarkNegatives>false</xr:MarkNegatives>"
X "$indent`t<xr:MinValue xsi:nil=`"true`"/>"
Emit-MLText "$indent`t" "xr:Synonym" $syn
X "$indent`t<xr:Comment/>"
if ($cmt) { X "$indent`t<xr:Comment>$(Esc-XmlText "$cmt")</xr:Comment>" } else { X "$indent`t<xr:Comment/>" }
X "$indent`t<xr:FullTextSearch>$fts</xr:FullTextSearch>"
X "$indent`t<xr:ChoiceParameterLinks/>"
X "$indent`t<xr:FillValue xsi:nil=`"true`"/>"
X "$indent`t<xr:Mask/>"
X "$indent`t<xr:ChoiceParameters/>"
Emit-ChoiceParameterLinks "$indent`t" (OvOr 'ChoiceParameterLinks' $null) 'xr:ChoiceParameterLinks'
# FillValue: дефолт nil; override-значение → типизированное (Normalize-ChoiceValue: DTR-путь/строка/bool).
$fvRaw = OvOr 'FillValue' $null
if ($null -eq $fvRaw) { X "$indent`t<xr:FillValue xsi:nil=`"true`"/>" }
else {
$fvN = Normalize-ChoiceValue $fvRaw
if ([string]::IsNullOrEmpty($fvN.Text)) { X "$indent`t<xr:FillValue xsi:type=`"$($fvN.XsiType)`"/>" }
else { X "$indent`t<xr:FillValue xsi:type=`"$($fvN.XsiType)`">$(Esc-Xml $fvN.Text)</xr:FillValue>" }
}
if ($msk) { X "$indent`t<xr:Mask>$(Esc-XmlText "$msk")</xr:Mask>" } else { X "$indent`t<xr:Mask/>" }
Emit-ChoiceParameters "$indent`t" (OvOr 'ChoiceParameters' $null) 'xr:ChoiceParameters'
X "$indent</xr:StandardAttribute>"
}
@@ -1101,6 +1111,12 @@ function Emit-StandardAttributes {
if ($null -ne $d.fillFromFillingValue) { $ov['FillFromFillingValue'] = if ($d.fillFromFillingValue) { 'true' } else { 'false' } }
if ($d.fullTextSearch) { $ov['FullTextSearch'] = "$($d.fullTextSearch)" }
if ($d.dataHistory) { $ov['DataHistory'] = "$($d.dataHistory)" }
if ($null -ne $d.fillValue) { $ov['FillValue'] = $d.fillValue } # DTR-путь/строка/bool
if ($null -ne $d.choiceParameterLinks) { $ov['ChoiceParameterLinks'] = $d.choiceParameterLinks }
if ($null -ne $d.choiceParameters) { $ov['ChoiceParameters'] = $d.choiceParameters }
if ($d.comment) { $ov['Comment'] = "$($d.comment)" }
if ($d.mask) { $ov['Mask'] = "$($d.mask)" }
if ($d.choiceForm) { $ov['ChoiceForm'] = "$($d.choiceForm)" }
}
}
Emit-StandardAttribute "$indent`t" $a $ov
@@ -1274,9 +1290,9 @@ function ConvertFrom-ChLinkShorthand {
# <ChoiceParameters> — [{name, value?}]. Значение ПРЯМО на app:value (xsi:type=тип); массив → v8:FixedArray
# с детьми v8:Value; без value → app:value nil.
function Emit-ChoiceParameters {
param([string]$indent, $cp)
if (-not $cp -or @($cp).Count -eq 0) { X "$indent<ChoiceParameters/>"; return }
X "$indent<ChoiceParameters>"
param([string]$indent, $cp, [string]$tag = 'ChoiceParameters')
if (-not $cp -or @($cp).Count -eq 0) { X "$indent<$tag/>"; return }
X "$indent<$tag>"
foreach ($item in @($cp)) {
if ($item -is [string]) { $item = ConvertFrom-ChParamShorthand $item }
$name = Get-ChElProp $item @('name','имя')
@@ -1308,14 +1324,14 @@ function Emit-ChoiceParameters {
}
X "$indent`t</app:item>"
}
X "$indent</ChoiceParameters>"
X "$indent</$tag>"
}
# <ChoiceParameterLinks> — [{name, dataPath, valueChange?}]. valueChange дефолт Clear.
function Emit-ChoiceParameterLinks {
param([string]$indent, $cpl)
if (-not $cpl -or @($cpl).Count -eq 0) { X "$indent<ChoiceParameterLinks/>"; return }
X "$indent<ChoiceParameterLinks>"
param([string]$indent, $cpl, [string]$tag = 'ChoiceParameterLinks')
if (-not $cpl -or @($cpl).Count -eq 0) { X "$indent<$tag/>"; return }
X "$indent<$tag>"
foreach ($lk in @($cpl)) {
if ($lk -is [string]) { $lk = ConvertFrom-ChLinkShorthand $lk }
$name = Get-ChElProp $lk @('name','имя')
@@ -1335,7 +1351,7 @@ function Emit-ChoiceParameterLinks {
X "$indent`t`t<xr:ValueChange>$vc</xr:ValueChange>"
X "$indent`t</xr:Link>"
}
X "$indent</ChoiceParameterLinks>"
X "$indent</$tag>"
}
# --- Characteristics (привязка ПВХ «Дополнительные реквизиты и сведения») ---
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# meta-compile v1.26 — Compile 1C metadata object from JSON
# meta-compile v1.27 — Compile 1C metadata object from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
@@ -1057,6 +1057,9 @@ def emit_standard_attribute(indent, attr_name, ov=None):
fts = ov.get('FullTextSearch', 'Use')
syn = ov.get('Synonym', '')
tt = ov.get('ToolTip', '')
cf = ov.get('ChoiceForm', '')
cmt = ov.get('Comment', '')
msk = ov.get('Mask', '')
X(f'{indent}<xr:StandardAttribute name="{attr_name}">')
X(f'{indent}\t<xr:LinkByType/>')
X(f'{indent}\t<xr:FillChecking>{fc}</xr:FillChecking>')
@@ -1067,7 +1070,10 @@ def emit_standard_attribute(indent, attr_name, ov=None):
emit_mltext(f'{indent}\t', 'xr:ToolTip', tt)
X(f'{indent}\t<xr:ExtendedEdit>false</xr:ExtendedEdit>')
X(f'{indent}\t<xr:Format/>')
X(f'{indent}\t<xr:ChoiceForm/>')
if cf:
X(f'{indent}\t<xr:ChoiceForm>{esc_xml(str(cf))}</xr:ChoiceForm>')
else:
X(f'{indent}\t<xr:ChoiceForm/>')
X(f'{indent}\t<xr:QuickChoice>Auto</xr:QuickChoice>')
X(f'{indent}\t<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>')
X(f'{indent}\t<xr:EditFormat/>')
@@ -1076,12 +1082,26 @@ def emit_standard_attribute(indent, attr_name, ov=None):
X(f'{indent}\t<xr:MarkNegatives>false</xr:MarkNegatives>')
X(f'{indent}\t<xr:MinValue xsi:nil="true"/>')
emit_mltext(f'{indent}\t', 'xr:Synonym', syn)
X(f'{indent}\t<xr:Comment/>')
if cmt:
X(f'{indent}\t<xr:Comment>{esc_xml_text(str(cmt))}</xr:Comment>')
else:
X(f'{indent}\t<xr:Comment/>')
X(f'{indent}\t<xr:FullTextSearch>{fts}</xr:FullTextSearch>')
X(f'{indent}\t<xr:ChoiceParameterLinks/>')
X(f'{indent}\t<xr:FillValue xsi:nil="true"/>')
X(f'{indent}\t<xr:Mask/>')
X(f'{indent}\t<xr:ChoiceParameters/>')
emit_choice_parameter_links(f'{indent}\t', ov.get('ChoiceParameterLinks'), 'xr:ChoiceParameterLinks')
fv_raw = ov.get('FillValue', None)
if fv_raw is None:
X(f'{indent}\t<xr:FillValue xsi:nil="true"/>')
else:
fv_xt, fv_tx = normalize_choice_value(fv_raw)
if fv_tx == '' or fv_tx is None:
X(f'{indent}\t<xr:FillValue xsi:type="{fv_xt}"/>')
else:
X(f'{indent}\t<xr:FillValue xsi:type="{fv_xt}">{esc_xml(fv_tx)}</xr:FillValue>')
if msk:
X(f'{indent}\t<xr:Mask>{esc_xml_text(str(msk))}</xr:Mask>')
else:
X(f'{indent}\t<xr:Mask/>')
emit_choice_parameters(f'{indent}\t', ov.get('ChoiceParameters'), 'xr:ChoiceParameters')
X(f'{indent}</xr:StandardAttribute>')
# Единый эмиттер блока StandardAttributes — поведение правят ДАННЫЕ, не форк кода (см. коммент в .ps1).
@@ -1115,6 +1135,18 @@ def emit_standard_attributes(indent, object_type):
ov['FullTextSearch'] = str(d['fullTextSearch'])
if d.get('dataHistory'):
ov['DataHistory'] = str(d['dataHistory'])
if d.get('fillValue') is not None:
ov['FillValue'] = d['fillValue']
if d.get('choiceParameterLinks') is not None:
ov['ChoiceParameterLinks'] = d['choiceParameterLinks']
if d.get('choiceParameters') is not None:
ov['ChoiceParameters'] = d['choiceParameters']
if d.get('comment'):
ov['Comment'] = str(d['comment'])
if d.get('mask'):
ov['Mask'] = str(d['mask'])
if d.get('choiceForm'):
ov['ChoiceForm'] = str(d['choiceForm'])
emit_standard_attribute(f'{indent}\t', a, ov)
X(f'{indent}</StandardAttributes>')
@@ -1331,13 +1363,13 @@ def convert_from_ch_link_shorthand(s):
o['dataPath'] = rest
return o
def emit_choice_parameters(indent, cp):
def emit_choice_parameters(indent, cp, tag='ChoiceParameters'):
if not cp:
X(f'{indent}<ChoiceParameters/>')
X(f'{indent}<{tag}/>')
return
if isinstance(cp, (str, dict)):
cp = [cp]
X(f'{indent}<ChoiceParameters>')
X(f'{indent}<{tag}>')
for item in cp:
if isinstance(item, str):
item = convert_from_ch_param_shorthand(item)
@@ -1365,15 +1397,15 @@ def emit_choice_parameters(indent, cp):
else:
X(f'{indent}\t\t<app:value xsi:type="{xt}">{esc_xml(tx)}</app:value>')
X(f'{indent}\t</app:item>')
X(f'{indent}</ChoiceParameters>')
X(f'{indent}</{tag}>')
def emit_choice_parameter_links(indent, cpl):
def emit_choice_parameter_links(indent, cpl, tag='ChoiceParameterLinks'):
if not cpl:
X(f'{indent}<ChoiceParameterLinks/>')
X(f'{indent}<{tag}/>')
return
if isinstance(cpl, (str, dict)):
cpl = [cpl]
X(f'{indent}<ChoiceParameterLinks>')
X(f'{indent}<{tag}>')
for lk in cpl:
if isinstance(lk, str):
lk = convert_from_ch_link_shorthand(lk)
@@ -1394,7 +1426,7 @@ def emit_choice_parameter_links(indent, cpl):
X(f'{indent}\t\t<xr:DataPath xsi:type="xs:string">{esc_xml(str(dp))}</xr:DataPath>')
X(f'{indent}\t\t<xr:ValueChange>{vc}</xr:ValueChange>')
X(f'{indent}\t</xr:Link>')
X(f'{indent}</ChoiceParameterLinks>')
X(f'{indent}</{tag}>')
# --- Characteristics (привязка ПВХ «Дополнительные реквизиты и сведения») ---
@@ -1,4 +1,4 @@
# meta-decompile v0.17 — XML объекта метаданных 1С → JSON-черновик формата meta-compile
# meta-decompile v0.18 — XML объекта метаданных 1С → JSON-черновик формата meta-compile
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
#
# Пилот: только Catalog. Инверс meta-compile (omit-on-default: ключ эмитим только
@@ -209,6 +209,41 @@ function Get-ChoiceParamValue {
return Convert-ChScalarNode $valNode
}
# <ChoiceParameterLinks> → [{name,dataPath,valueChange?}] | строки "name=dataPath". $tag: 'md:...' (реквизит) | 'xr:...' (станд.).
function Parse-ChoiceParameterLinks {
param($parent, [string]$tag)
$node = $parent.SelectSingleNode($tag, $nsm)
if (-not $node) { return $null }
$links = @($node.SelectNodes('xr:Link', $nsm))
if ($links.Count -eq 0) { return $null }
$arr = [System.Collections.ArrayList]@()
foreach ($lk in $links) {
$lName = $lk.SelectSingleNode('xr:Name', $nsm).InnerText
$lDp = $lk.SelectSingleNode('xr:DataPath', $nsm).InnerText
$vcN = $lk.SelectSingleNode('xr:ValueChange', $nsm); $vcv = if ($vcN) { $vcN.InnerText } else { 'Clear' }
if ($vcv -eq 'Clear') { [void]$arr.Add("$lName=$lDp") }
else { [void]$arr.Add([ordered]@{ name = $lName; dataPath = $lDp; valueChange = $vcv }) }
}
return $arr
}
# <ChoiceParameters> → [{name,value?}]. $tag: 'md:...' | 'xr:...'.
function Parse-ChoiceParameters {
param($parent, [string]$tag)
$node = $parent.SelectSingleNode($tag, $nsm)
if (-not $node) { return $null }
$items = @($node.SelectNodes('app:item', $nsm))
if ($items.Count -eq 0) { return $null }
$arr = [System.Collections.ArrayList]@()
foreach ($it in $items) {
$pName = $it.GetAttribute('name')
$valN = $it.SelectSingleNode('app:value', $nsm)
$nilAttr = if ($valN) { $valN.GetAttribute('nil', 'http://www.w3.org/2001/XMLSchema-instance') } else { '' }
if (-not $valN -or $nilAttr -eq 'true') { [void]$arr.Add([ordered]@{ name = $pName }) }
else { $o = [ordered]@{ name = $pName }; $o['value'] = Get-ChoiceParamValue $valN; [void]$arr.Add($o) }
}
return $arr
}
# --- Реквизит → DSL: shorthand-строка "Имя: Тип | флаги" ЛИБО object-форма при кастомном синониме.
# (Синоним ≠ авто → object {name, type, synonym, [flags]}; иначе компактный shorthand.) ---
function Attr-ToDsl {
@@ -289,45 +324,8 @@ function Attr-ToDsl {
}
}
# ChoiceParameterLinks — [{name, dataPath, valueChange?}]. valueChange=Clear → компактно строкой "name=dataPath".
$cplNode = $ap.SelectSingleNode('md:ChoiceParameterLinks', $nsm)
if ($cplNode) {
$links = @($cplNode.SelectNodes('xr:Link', $nsm))
if ($links.Count -gt 0) {
$arr = [System.Collections.ArrayList]@()
foreach ($lk in $links) {
$lName = $lk.SelectSingleNode('xr:Name', $nsm).InnerText
$lDp = $lk.SelectSingleNode('xr:DataPath', $nsm).InnerText
$vcN = $lk.SelectSingleNode('xr:ValueChange', $nsm)
$vcv = if ($vcN) { $vcN.InnerText } else { 'Clear' }
if ($vcv -eq 'Clear') { [void]$arr.Add("$lName=$lDp") }
else { [void]$arr.Add([ordered]@{ name = $lName; dataPath = $lDp; valueChange = $vcv }) }
}
$extra['choiceParameterLinks'] = $arr
}
}
# ChoiceParameters — [{name, value?}]. app:value nil → без value; иначе типизированное значение.
$cpNode = $ap.SelectSingleNode('md:ChoiceParameters', $nsm)
if ($cpNode) {
$items = @($cpNode.SelectNodes('app:item', $nsm))
if ($items.Count -gt 0) {
$arr = [System.Collections.ArrayList]@()
foreach ($it in $items) {
$pName = $it.GetAttribute('name')
$valN = $it.SelectSingleNode('app:value', $nsm)
$nilAttr = if ($valN) { $valN.GetAttribute('nil', 'http://www.w3.org/2001/XMLSchema-instance') } else { '' }
if (-not $valN -or $nilAttr -eq 'true') {
[void]$arr.Add([ordered]@{ name = $pName })
} else {
$o = [ordered]@{ name = $pName }
$o['value'] = Get-ChoiceParamValue $valN
[void]$arr.Add($o)
}
}
$extra['choiceParameters'] = $arr
}
}
$cplArr = Parse-ChoiceParameterLinks $ap 'md:ChoiceParameterLinks'; if ($null -ne $cplArr) { $extra['choiceParameterLinks'] = $cplArr }
$cpArr = Parse-ChoiceParameters $ap 'md:ChoiceParameters'; if ($null -ne $cpArr) { $extra['choiceParameters'] = $cpArr }
if ($synCustom -or ($null -ne $ttVal) -or $extra.Count -gt 0) {
$o = [ordered]@{ name = $nm }
@@ -487,6 +485,14 @@ if ($saNode) {
# FullTextSearch / DataHistory (профиль = Use)
$ftsN = $sa.SelectSingleNode('xr:FullTextSearch', $nsm); if ($ftsN -and $ftsN.InnerText -ne 'Use') { $ov['fullTextSearch'] = $ftsN.InnerText }
$dhN = $sa.SelectSingleNode('xr:DataHistory', $nsm); if ($dhN -and $dhN.InnerText -ne 'Use') { $ov['dataHistory'] = $dhN.InnerText }
# FillValue (дефолт nil) — DTR-путь/строка/bool. Comment/Mask/ChoiceForm (дефолт пусто).
$fvN = $sa.SelectSingleNode('xr:FillValue', $nsm)
if ($fvN -and $fvN.GetAttribute('nil', 'http://www.w3.org/2001/XMLSchema-instance') -ne 'true') { $ov['fillValue'] = Convert-ChScalarNode $fvN }
$saCmt = $sa.SelectSingleNode('xr:Comment', $nsm); if ($saCmt -and $saCmt.InnerText) { $ov['comment'] = $saCmt.InnerText }
$saMsk = $sa.SelectSingleNode('xr:Mask', $nsm); if ($saMsk -and $saMsk.InnerText) { $ov['mask'] = $saMsk.InnerText }
$saCf = $sa.SelectSingleNode('xr:ChoiceForm', $nsm); if ($saCf -and $saCf.InnerText) { $ov['choiceForm'] = $saCf.InnerText }
$saCpl = Parse-ChoiceParameterLinks $sa 'xr:ChoiceParameterLinks'; if ($null -ne $saCpl) { $ov['choiceParameterLinks'] = $saCpl }
$saCp = Parse-ChoiceParameters $sa 'xr:ChoiceParameters'; if ($null -ne $saCp) { $ov['choiceParameters'] = $saCp }
if ($ov.Count -gt 0) { $saMap[$an] = $ov }
}
$dsl['standardAttributes'] = $saMap # даже пустой = блок есть (чистый профиль)