mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-20 17:40:59 +03:00
feat(skd): локальный xmlns + use=false на nested sub-items outputParameters
В chart-параметрах типа ТипДиаграммы.СоединениеЗначенийПоСериям platform эмитит nested SettingsParameterValue с: - <dcscor:use>false</dcscor:use> (sub-параметр отключён) - <dcscor:value xmlns:dN="http://v8.1c.ru/8.2/data/chart" xsi:type="dN:X"> (локальный xmlns на value — префикс не объявлен в корне схемы) Раньше теряли оба: - decompile не читал sub.use и не резолвил xmlns кастомного xsi:type - compile эмитил value без xmlns и без use=false decompile: читаем dcscor:use на sub-item, резолвим prefix→URI через GetNamespaceOfPrefix; если URI не из стандартных корневых xmlns — сохраняем valueType как объект {uri, name}. compile (PS+Py): новый helper Emit-OutputParametersSubItem; если valueType — объект, эмитим xmlns:dN=<uri> + xsi:type=dN:<name>; + <dcscor:use>false</dcscor:use> если sub.use === false. Sample30 total: 809 → 794 строк diff.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# skd-compile v1.92 — Compile 1C DCS from JSON
|
# skd-compile v1.93 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$DefinitionFile,
|
[string]$DefinitionFile,
|
||||||
@@ -2482,6 +2482,55 @@ function Emit-ConditionalAppearance {
|
|||||||
X "$indent</dcsset:conditionalAppearance>"
|
X "$indent</dcsset:conditionalAppearance>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Эмиссия nested sub-item внутри SettingsParameterValue (chart-параметры типа
|
||||||
|
# ТипДиаграммы.СоединениеЗначенийПоСериям). Поддерживает use=false и valueType
|
||||||
|
# либо строкой ("xs:string", "dN:Foo" если префикс известен в корне), либо
|
||||||
|
# объектом {uri, name} — эмитим локальный xmlns на value.
|
||||||
|
function Emit-OutputParametersSubItem {
|
||||||
|
param([string]$subName, $subWrap, [string]$indent)
|
||||||
|
$subVal = $subWrap
|
||||||
|
$subVT = 'xs:string'
|
||||||
|
$subUseFalse = $false
|
||||||
|
$subUri = $null
|
||||||
|
$subLocalName = $null
|
||||||
|
if ($subWrap -is [PSCustomObject]) {
|
||||||
|
if ($subWrap.PSObject.Properties['value']) { $subVal = $subWrap.value }
|
||||||
|
if ($subWrap.PSObject.Properties['valueType']) {
|
||||||
|
$vt = $subWrap.valueType
|
||||||
|
if ($vt -is [PSCustomObject] -and $vt.PSObject.Properties['uri']) {
|
||||||
|
$subUri = "$($vt.uri)"; $subLocalName = "$($vt.name)"
|
||||||
|
} elseif ($vt -is [System.Collections.IDictionary] -and $vt.Contains('uri')) {
|
||||||
|
$subUri = "$($vt['uri'])"; $subLocalName = "$($vt['name'])"
|
||||||
|
} else {
|
||||||
|
$subVT = "$vt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($subWrap.PSObject.Properties['use'] -and $subWrap.use -eq $false) { $subUseFalse = $true }
|
||||||
|
} elseif ($subWrap -is [System.Collections.IDictionary]) {
|
||||||
|
if ($subWrap.Contains('value')) { $subVal = $subWrap['value'] }
|
||||||
|
if ($subWrap.Contains('valueType')) {
|
||||||
|
$vt = $subWrap['valueType']
|
||||||
|
if ($vt -is [PSCustomObject] -and $vt.PSObject.Properties['uri']) {
|
||||||
|
$subUri = "$($vt.uri)"; $subLocalName = "$($vt.name)"
|
||||||
|
} elseif ($vt -is [System.Collections.IDictionary] -and $vt.Contains('uri')) {
|
||||||
|
$subUri = "$($vt['uri'])"; $subLocalName = "$($vt['name'])"
|
||||||
|
} else {
|
||||||
|
$subVT = "$vt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($subWrap.Contains('use') -and $subWrap['use'] -eq $false) { $subUseFalse = $true }
|
||||||
|
}
|
||||||
|
X "$indent`t`t<dcscor:item xsi:type=`"dcsset:SettingsParameterValue`">"
|
||||||
|
if ($subUseFalse) { X "$indent`t`t`t<dcscor:use>false</dcscor:use>" }
|
||||||
|
X "$indent`t`t`t<dcscor:parameter>$(Esc-Xml $subName)</dcscor:parameter>"
|
||||||
|
if ($subUri) {
|
||||||
|
X "$indent`t`t`t<dcscor:value xmlns:dN=`"$subUri`" xsi:type=`"dN:$subLocalName`">$(Esc-Xml "$subVal")</dcscor:value>"
|
||||||
|
} else {
|
||||||
|
X "$indent`t`t`t<dcscor:value xsi:type=`"$subVT`">$(Esc-Xml "$subVal")</dcscor:value>"
|
||||||
|
}
|
||||||
|
X "$indent`t`t</dcscor:item>"
|
||||||
|
}
|
||||||
|
|
||||||
function Emit-OutputParameters {
|
function Emit-OutputParameters {
|
||||||
param($params, [string]$indent, $blockViewMode = $null)
|
param($params, [string]$indent, $blockViewMode = $null)
|
||||||
|
|
||||||
@@ -2559,28 +2608,17 @@ function Emit-OutputParameters {
|
|||||||
} else {
|
} else {
|
||||||
X "$indent`t`t<dcscor:value xsi:type=`"$ptype`">$(Esc-Xml "$rawVal")</dcscor:value>"
|
X "$indent`t`t<dcscor:value xsi:type=`"$ptype`">$(Esc-Xml "$rawVal")</dcscor:value>"
|
||||||
}
|
}
|
||||||
# Nested sub-параметры (ТипДиаграммы.ВидПодписей и т.п.) — эмитим между value и extras
|
# Nested sub-параметры (ТипДиаграммы.ВидПодписей и т.п.) — эмитим между value и extras.
|
||||||
|
# valueType: строка → xsi:type=string, объект {uri, name} → локальный xmlns:dN + xsi:type=dN:name.
|
||||||
if ($wrapItems) {
|
if ($wrapItems) {
|
||||||
$itemProps = if ($wrapItems -is [PSCustomObject]) { $wrapItems.PSObject.Properties } else { $null }
|
$itemProps = if ($wrapItems -is [PSCustomObject]) { $wrapItems.PSObject.Properties } else { $null }
|
||||||
if ($itemProps) {
|
if ($itemProps) {
|
||||||
foreach ($ip in $itemProps) {
|
foreach ($ip in $itemProps) {
|
||||||
$subName = $ip.Name; $subWrap = $ip.Value
|
Emit-OutputParametersSubItem -subName $ip.Name -subWrap $ip.Value -indent $indent
|
||||||
$subVal = if ($subWrap -is [PSCustomObject] -and $subWrap.PSObject.Properties['value']) { $subWrap.value } else { $subWrap }
|
|
||||||
$subVT = if ($subWrap -is [PSCustomObject] -and $subWrap.PSObject.Properties['valueType']) { "$($subWrap.valueType)" } else { 'xs:string' }
|
|
||||||
X "$indent`t`t<dcscor:item xsi:type=`"dcsset:SettingsParameterValue`">"
|
|
||||||
X "$indent`t`t`t<dcscor:parameter>$(Esc-Xml $subName)</dcscor:parameter>"
|
|
||||||
X "$indent`t`t`t<dcscor:value xsi:type=`"$subVT`">$(Esc-Xml "$subVal")</dcscor:value>"
|
|
||||||
X "$indent`t`t</dcscor:item>"
|
|
||||||
}
|
}
|
||||||
} elseif ($wrapItems -is [System.Collections.IDictionary]) {
|
} elseif ($wrapItems -is [System.Collections.IDictionary]) {
|
||||||
foreach ($k in $wrapItems.Keys) {
|
foreach ($k in $wrapItems.Keys) {
|
||||||
$subWrap = $wrapItems[$k]
|
Emit-OutputParametersSubItem -subName $k -subWrap $wrapItems[$k] -indent $indent
|
||||||
$subVal = if ($subWrap -is [System.Collections.IDictionary] -and $subWrap.Contains('value')) { $subWrap['value'] } else { $subWrap }
|
|
||||||
$subVT = if ($subWrap -is [System.Collections.IDictionary] -and $subWrap.Contains('valueType')) { "$($subWrap['valueType'])" } else { 'xs:string' }
|
|
||||||
X "$indent`t`t<dcscor:item xsi:type=`"dcsset:SettingsParameterValue`">"
|
|
||||||
X "$indent`t`t`t<dcscor:parameter>$(Esc-Xml $k)</dcscor:parameter>"
|
|
||||||
X "$indent`t`t`t<dcscor:value xsi:type=`"$subVT`">$(Esc-Xml "$subVal")</dcscor:value>"
|
|
||||||
X "$indent`t`t</dcscor:item>"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# skd-compile v1.92 — Compile 1C DCS from JSON
|
# skd-compile v1.93 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -2081,18 +2081,35 @@ def emit_output_parameters(lines, params, indent):
|
|||||||
emit_mltext(lines, f'{indent}\t\t', 'dcscor:value', val)
|
emit_mltext(lines, f'{indent}\t\t', 'dcscor:value', val)
|
||||||
else:
|
else:
|
||||||
lines.append(f'{indent}\t\t<dcscor:value xsi:type="{ptype}">{esc_xml(str(val))}</dcscor:value>')
|
lines.append(f'{indent}\t\t<dcscor:value xsi:type="{ptype}">{esc_xml(str(val))}</dcscor:value>')
|
||||||
# Nested sub-параметры (ТипДиаграммы.ВидПодписей и т.п.)
|
# Nested sub-параметры (ТипДиаграммы.ВидПодписей и т.п.).
|
||||||
|
# valueType: строка → xsi:type=string, объект {uri, name} → локальный xmlns:dN.
|
||||||
if wrap_items and isinstance(wrap_items, dict):
|
if wrap_items and isinstance(wrap_items, dict):
|
||||||
for sub_name, sub_wrap in wrap_items.items():
|
for sub_name, sub_wrap in wrap_items.items():
|
||||||
if isinstance(sub_wrap, dict) and 'value' in sub_wrap:
|
sub_val = sub_wrap
|
||||||
sub_val = sub_wrap['value']
|
sub_vt = 'xs:string'
|
||||||
sub_vt = sub_wrap.get('valueType', 'xs:string')
|
sub_use_false = False
|
||||||
else:
|
sub_uri = None
|
||||||
sub_val = sub_wrap
|
sub_local_name = None
|
||||||
sub_vt = 'xs:string'
|
if isinstance(sub_wrap, dict):
|
||||||
|
if 'value' in sub_wrap:
|
||||||
|
sub_val = sub_wrap['value']
|
||||||
|
if 'valueType' in sub_wrap:
|
||||||
|
vt = sub_wrap['valueType']
|
||||||
|
if isinstance(vt, dict) and 'uri' in vt:
|
||||||
|
sub_uri = str(vt['uri'])
|
||||||
|
sub_local_name = str(vt['name'])
|
||||||
|
else:
|
||||||
|
sub_vt = str(vt)
|
||||||
|
if sub_wrap.get('use') is False:
|
||||||
|
sub_use_false = True
|
||||||
lines.append(f'{indent}\t\t<dcscor:item xsi:type="dcsset:SettingsParameterValue">')
|
lines.append(f'{indent}\t\t<dcscor:item xsi:type="dcsset:SettingsParameterValue">')
|
||||||
|
if sub_use_false:
|
||||||
|
lines.append(f'{indent}\t\t\t<dcscor:use>false</dcscor:use>')
|
||||||
lines.append(f'{indent}\t\t\t<dcscor:parameter>{esc_xml(sub_name)}</dcscor:parameter>')
|
lines.append(f'{indent}\t\t\t<dcscor:parameter>{esc_xml(sub_name)}</dcscor:parameter>')
|
||||||
lines.append(f'{indent}\t\t\t<dcscor:value xsi:type="{sub_vt}">{esc_xml(str(sub_val))}</dcscor:value>')
|
if sub_uri:
|
||||||
|
lines.append(f'{indent}\t\t\t<dcscor:value xmlns:dN="{sub_uri}" xsi:type="dN:{sub_local_name}">{esc_xml(str(sub_val))}</dcscor:value>')
|
||||||
|
else:
|
||||||
|
lines.append(f'{indent}\t\t\t<dcscor:value xsi:type="{sub_vt}">{esc_xml(str(sub_val))}</dcscor:value>')
|
||||||
lines.append(f'{indent}\t\t</dcscor:item>')
|
lines.append(f'{indent}\t\t</dcscor:item>')
|
||||||
if wrap_vm:
|
if wrap_vm:
|
||||||
lines.append(f'{indent}\t\t<dcsset:viewMode>{esc_xml(str(wrap_vm))}</dcsset:viewMode>')
|
lines.append(f'{indent}\t\t<dcsset:viewMode>{esc_xml(str(wrap_vm))}</dcsset:viewMode>')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# skd-decompile v0.75 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
# skd-decompile v0.76 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -1846,8 +1846,29 @@ function Build-OutputParameters {
|
|||||||
if ($subType -eq 'LocalStringType') { $subRaw = Get-MLText $subVal }
|
if ($subType -eq 'LocalStringType') { $subRaw = Get-MLText $subVal }
|
||||||
elseif ($subType -eq 'Font') { $subRaw = Get-FontValue $subVal }
|
elseif ($subType -eq 'Font') { $subRaw = Get-FontValue $subVal }
|
||||||
else { $subRaw = $subVal.InnerText }
|
else { $subRaw = $subVal.InnerText }
|
||||||
# Сохраняем как {value, valueType} чтобы compile воспроизвёл xsi:type
|
# Резолвим prefix → URI: если URI не из стандартных корневых xmlns —
|
||||||
$nestedItems[$subName] = [ordered]@{ value = $subRaw; valueType = $subFull }
|
# сохраняем как объект {uri, name} чтобы compile эмитил xmlns локально.
|
||||||
|
$subTypeField = $subFull
|
||||||
|
if ($subFull -and $subFull -match '^([^:]+):(.+)$') {
|
||||||
|
$pfx = $matches[1]; $localName = $matches[2]
|
||||||
|
$uri = $subVal.GetNamespaceOfPrefix($pfx)
|
||||||
|
if ($uri -and $uri -notin @(
|
||||||
|
'http://www.w3.org/2001/XMLSchema',
|
||||||
|
'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
|
'http://v8.1c.ru/8.1/data-composition-system/schema',
|
||||||
|
'http://v8.1c.ru/8.1/data-composition-system/settings',
|
||||||
|
'http://v8.1c.ru/8.1/data-composition-system/core',
|
||||||
|
'http://v8.1c.ru/8.1/data-composition-system/common',
|
||||||
|
'http://v8.1c.ru/8.1/data/core',
|
||||||
|
'http://v8.1c.ru/8.1/data/ui'
|
||||||
|
)) {
|
||||||
|
$subTypeField = [ordered]@{ uri = $uri; name = $localName }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$entry = [ordered]@{ value = $subRaw; valueType = $subTypeField }
|
||||||
|
$subUse = Get-Text $sub "dcscor:use"
|
||||||
|
if ($subUse -eq 'false') { $entry['use'] = $false }
|
||||||
|
$nestedItems[$subName] = $entry
|
||||||
}
|
}
|
||||||
# Extras (use=false / viewMode / userSettingID / userSettingPresentation / nested items) → wrapper.
|
# Extras (use=false / viewMode / userSettingID / userSettingPresentation / nested items) → wrapper.
|
||||||
$useV = Get-Text $it "dcscor:use"
|
$useV = Get-Text $it "dcscor:use"
|
||||||
|
|||||||
Reference in New Issue
Block a user