feat(skd): кастомные xsi:type с локальным xmlns в inputParameters values

Параметр ВыборГруппИЭлементов имеет значение типа FoldersAndItemsUse:
<dcscor:value xmlns:d6p1="http://v8.1c.ru/8.1/data/enterprise"
 xsi:type="d6p1:FoldersAndItemsUse">Items</dcscor:value>

Decompile теряла xsi:type → compile эмитил xs:string. Теперь сохраняем
{uri, name} в valueType wrapper'е, compile воспроизводит локальный
xmlns:dN="..." prefix и правильный xsi:type. GetNamespaceOfPrefix
извлекает URI из контекста элемента, что работает для всех 7 известных
xmlns URI (enterprise, current-config, ui/style, chart, types и т.п.).

sample30: −8 строк (1556 → 1548).
This commit is contained in:
Nick Shirokov
2026-05-23 20:24:46 +03:00
parent 9ef554a576
commit 639568c039
3 changed files with 40 additions and 5 deletions
@@ -1,4 +1,4 @@
# skd-compile v1.79 — Compile 1C DCS from JSON
# skd-compile v1.80 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$DefinitionFile,
@@ -799,7 +799,23 @@ function Emit-InputParameters {
} elseif (Has-JsonProp $item 'value') {
# Simple typed value — определяем xsi:type из JSON-типа
$val = $item.value
if ($val -is [bool]) {
# Явный кастомный type из decompile: {uri, name} → <value xmlns:dN="uri" xsi:type="dN:name">
$customType = $null
if (Has-JsonProp $item 'valueType') {
$vtSrc = $item.valueType
$uri = $null; $tName = $null
if ($vtSrc -is [PSCustomObject]) {
if ($vtSrc.PSObject.Properties['uri']) { $uri = "$($vtSrc.uri)" }
if ($vtSrc.PSObject.Properties['name']) { $tName = "$($vtSrc.name)" }
} elseif ($vtSrc -is [System.Collections.IDictionary]) {
if ($vtSrc.Contains('uri')) { $uri = "$($vtSrc['uri'])" }
if ($vtSrc.Contains('name')) { $tName = "$($vtSrc['name'])" }
}
if ($uri -and $tName) { $customType = @{ uri = $uri; name = $tName } }
}
if ($customType) {
X "$indent`t`t<dcscor:value xmlns:dN=`"$($customType.uri)`" xsi:type=`"dN:$($customType.name)`">$(Esc-Xml "$val")</dcscor:value>"
} elseif ($val -is [bool]) {
$vStr = if ($val) { 'true' } else { 'false' }
X "$indent`t`t<dcscor:value xsi:type=`"xs:boolean`">$vStr</dcscor:value>"
} elseif ($val -is [int] -or $val -is [long] -or $val -is [double] -or $val -is [decimal]) {
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# skd-compile v1.79 — Compile 1C DCS from JSON
# skd-compile v1.80 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import json
@@ -605,7 +605,15 @@ def emit_input_parameters(lines, ip, indent):
lines.append(f'{indent}\t\t</dcscor:value>')
elif 'value' in item:
val = item['value']
if isinstance(val, bool):
# Явный кастомный type из decompile: {uri, name}
vt_src = item.get('valueType')
custom_uri = None; custom_name = None
if isinstance(vt_src, dict):
custom_uri = vt_src.get('uri')
custom_name = vt_src.get('name')
if custom_uri and custom_name:
lines.append(f'{indent}\t\t<dcscor:value xmlns:dN="{custom_uri}" xsi:type="dN:{custom_name}">{esc_xml(str(val))}</dcscor:value>')
elif isinstance(val, bool):
vstr = 'true' if val else 'false'
lines.append(f'{indent}\t\t<dcscor:value xsi:type="xs:boolean">{vstr}</dcscor:value>')
elif isinstance(val, (int, float)):
@@ -1,4 +1,4 @@
# skd-decompile v0.65 — Decompile 1C DCS Template.xml to JSON DSL (draft)
# skd-decompile v0.66 — Decompile 1C DCS Template.xml to JSON DSL (draft)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory)]
@@ -523,6 +523,17 @@ function Read-InputParameters {
else { $entry['value'] = [double]$txt }
} else {
$entry['value'] = $txt
# Сохраняем кастомный xsi:type (например, "d6p1:FoldersAndItemsUse" с локальным xmlns).
# Не сохраняем xs:* (string/dateTime/etc) — compile auto-detect.
$ta = $val.Attributes['xsi:type']
if ($ta -and $ta.Value -notmatch '^xs:') {
$prefix = ($ta.Value -split ':', 2)[0]
$localName = ($ta.Value -split ':', 2)[1]
$uri = $val.GetNamespaceOfPrefix($prefix)
if ($uri) {
$entry['valueType'] = [ordered]@{ uri = $uri; name = $localName }
}
}
}
}
}