feat(skd): bool/numeric values в inputParameters choiceParameters

Раньше все values в <dcscor:value xsi:type="dcscor:ChoiceParameters">
эмитились как DesignTimeValue. Оригинал использует xs:boolean для bool-флагов
(пример: Отбор.ОбособленноеПодразделение=false в ChoiceParameters элементе
inputParameters поля ДанныеОрганизации).

decompile: читает тип xsi из <dcscor:value> и конвертит в JSON-native
(true/false для boolean, int/double для decimal, иначе строка).
compile: при эмите inputParameters → choiceParameters → values детектирует
тип значения и эмитит соответствующий xsi:type.

PS и Py синхронизированы.
This commit is contained in:
Nick Shirokov
2026-05-24 15:37:07 +03:00
parent 85d42ec34c
commit db6a1f2212
3 changed files with 30 additions and 6 deletions
@@ -1,4 +1,4 @@
# skd-compile v1.86 — Compile 1C DCS from JSON
# skd-compile v1.87 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$DefinitionFile,
@@ -773,7 +773,14 @@ function Emit-InputParameters {
X "$indent`t`t`t<dcscor:item>"
X "$indent`t`t`t`t<dcscor:choiceParameter>$(Esc-Xml "$($cpItem.name)")</dcscor:choiceParameter>"
foreach ($v in @($cpItem.values)) {
X "$indent`t`t`t`t<dcscor:value xsi:type=`"dcscor:DesignTimeValue`">$(Esc-Xml "$v")</dcscor:value>"
if ($v -is [bool]) {
$vStr = if ($v) { 'true' } else { 'false' }
X "$indent`t`t`t`t<dcscor:value xsi:type=`"xs:boolean`">$vStr</dcscor:value>"
} elseif ($v -is [int] -or $v -is [long] -or $v -is [double] -or $v -is [decimal]) {
X "$indent`t`t`t`t<dcscor:value xsi:type=`"xs:decimal`">$v</dcscor:value>"
} else {
X "$indent`t`t`t`t<dcscor:value xsi:type=`"dcscor:DesignTimeValue`">$(Esc-Xml "$v")</dcscor:value>"
}
}
X "$indent`t`t`t</dcscor:item>"
}
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# skd-compile v1.86 — Compile 1C DCS from JSON
# skd-compile v1.87 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import json
@@ -586,7 +586,13 @@ def emit_input_parameters(lines, ip, indent):
lines.append(f'{indent}\t\t\t<dcscor:item>')
lines.append(f'{indent}\t\t\t\t<dcscor:choiceParameter>{esc_xml(str(cp.get("name", "")))}</dcscor:choiceParameter>')
for v in cp.get('values', []) or []:
lines.append(f'{indent}\t\t\t\t<dcscor:value xsi:type="dcscor:DesignTimeValue">{esc_xml(str(v))}</dcscor:value>')
if isinstance(v, bool):
vs = 'true' if v else 'false'
lines.append(f'{indent}\t\t\t\t<dcscor:value xsi:type="xs:boolean">{vs}</dcscor:value>')
elif isinstance(v, (int, float)):
lines.append(f'{indent}\t\t\t\t<dcscor:value xsi:type="xs:decimal">{v}</dcscor:value>')
else:
lines.append(f'{indent}\t\t\t\t<dcscor:value xsi:type="dcscor:DesignTimeValue">{esc_xml(str(v))}</dcscor:value>')
lines.append(f'{indent}\t\t\t</dcscor:item>')
lines.append(f'{indent}\t\t</dcscor:value>')
elif 'choiceParameterLinks' in item:
@@ -1,4 +1,4 @@
# skd-decompile v0.69 — Decompile 1C DCS Template.xml to JSON DSL (draft)
# skd-decompile v0.70 — Decompile 1C DCS Template.xml to JSON DSL (draft)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory)]
@@ -492,7 +492,18 @@ function Read-InputParameters {
foreach ($cpItem in $val.SelectNodes("dcscor:item", $ns)) {
$cpEntry = [ordered]@{ name = Get-Text $cpItem "dcscor:choiceParameter" }
$values = @()
foreach ($v in $cpItem.SelectNodes("dcscor:value", $ns)) { $values += $v.InnerText }
foreach ($v in $cpItem.SelectNodes("dcscor:value", $ns)) {
$vXsi = Get-LocalXsiType $v
$vTxt = $v.InnerText
if ($vXsi -eq 'boolean') {
$values += ($vTxt -eq 'true')
} elseif ($vXsi -eq 'decimal') {
if ($vTxt -match '^-?\d+$') { $values += [int]$vTxt }
else { $values += [double]$vTxt }
} else {
$values += $vTxt
}
}
$cpEntry['values'] = $values
$cp += $cpEntry
}