mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 16:14:54 +03:00
fix(skd-edit): drop unneeded " → " in query/expression
Зеркалим решение из skd-compile: убираем .Replace('"','"') из Esc-Xml
и удаляем post-process, который принудительно ставил " внутри
<query>/<expression>. Реальный Конфигуратор так не пишет — экранирование
было анти-1С-стилем и портило round-trip diff.
Снимок add-calculated-field-restrict обновлён под новый формат.
Кейс preserve-entities-modify-parameter-title удалён: его смысл
инвертировался (теперь проверял бы нормализацию, а не сохранение),
а часть про многострочный xmlns уже покрыта preserve-xmlns-multiline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-edit v1.21 — Atomic 1C DCS editor
|
||||
# skd-edit v1.22 — Atomic 1C DCS editor
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -50,7 +50,7 @@ $resolvedPath = (Resolve-Path $TemplatePath).Path
|
||||
|
||||
function Esc-Xml {
|
||||
param([string]$s)
|
||||
return $s.Replace('&','&').Replace('<','<').Replace('>','>').Replace('"','"')
|
||||
return $s.Replace('&','&').Replace('<','<').Replace('>','>')
|
||||
}
|
||||
|
||||
function Resolve-QueryValue {
|
||||
@@ -3563,19 +3563,11 @@ if ($script:RawRootOpening) {
|
||||
$content = [regex]::Replace($content, '<DataCompositionSchema\b[^>]*>', { param($m) $script:RawRootOpening })
|
||||
}
|
||||
|
||||
# (2) re-escape `"` to " inside <query>/<expression> text content (1C-style).
|
||||
# Scope is anchored to those tag names so xsi:type="..." attribute quotes are untouched.
|
||||
$content = [regex]::Replace(
|
||||
$content,
|
||||
'(<(?:\w+:)?(?:query|expression)\b[^>]*>)([\s\S]*?)(</(?:\w+:)?(?:query|expression)>)',
|
||||
{ param($m) $m.Groups[1].Value + $m.Groups[2].Value.Replace('"', '"') + $m.Groups[3].Value }
|
||||
)
|
||||
|
||||
# (3) normalize self-closing tags: `.NET XmlDocument` adds a space before `/>`
|
||||
# (2) normalize self-closing tags: `.NET XmlDocument` adds a space before `/>`
|
||||
# (`<foo bar="x" />`) but 1C-Designer writes `<foo bar="x"/>`. Strip the space.
|
||||
$content = [regex]::Replace($content, '(?<=\S) />', '/>')
|
||||
|
||||
# (4) normalize line endings to match source — operations may mix LF (from new
|
||||
# (3) normalize line endings to match source — operations may mix LF (from new
|
||||
# fragments) with whatever the source used (CRLF on Windows, LF on Linux/git).
|
||||
if ($script:LineEnding -eq "`r`n") {
|
||||
$content = $content -replace '(?<!\r)\n', "`r`n"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-edit v1.21 — Atomic 1C DCS editor (Python port)
|
||||
# skd-edit v1.22 — Atomic 1C DCS editor (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import os
|
||||
@@ -80,7 +80,7 @@ def local_name(node):
|
||||
# ── helpers ──────────────────────────────────────────────────
|
||||
|
||||
def esc_xml(s):
|
||||
return s.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"')
|
||||
return s.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||
|
||||
|
||||
def resolve_query_value(val, base_dir):
|
||||
@@ -2946,16 +2946,9 @@ xml_bytes = xml_bytes.replace(b"<?xml version='1.0' encoding='UTF-8'?>", b'<?xml
|
||||
# Format-preserve post-processing (mirrors PS path):
|
||||
# (1) restore the original raw <DataCompositionSchema ...> opening tag — lxml collapses
|
||||
# multi-line xmlns into one line.
|
||||
# (2) re-escape `"` to " inside <query>/<expression> text content; scope anchored
|
||||
# to those tag names so xsi:type="..." attribute quotes are untouched.
|
||||
xml_text = xml_bytes.decode("utf-8")
|
||||
if raw_root_opening:
|
||||
xml_text = re.sub(r"<DataCompositionSchema\b[^>]*>", lambda m: raw_root_opening, xml_text, count=1, flags=re.DOTALL)
|
||||
xml_text = re.sub(
|
||||
r"(<(?:\w+:)?(?:query|expression)\b[^>]*>)([\s\S]*?)(</(?:\w+:)?(?:query|expression)>)",
|
||||
lambda m: m.group(1) + m.group(2).replace('"', '"') + m.group(3),
|
||||
xml_text,
|
||||
)
|
||||
# Normalize self-closing tags: lxml writes `<foo bar="x"/>` already (no space), but be
|
||||
# defensive — strip any space before `/>` so PS and PY ports stay byte-equivalent.
|
||||
xml_text = re.sub(r"(?<=\S) />", "/>", xml_text)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "modify-parameter title сохраняет " и многострочный xmlns в неизменённых местах",
|
||||
"setup": "fixture:roundtrip-base",
|
||||
"params": {
|
||||
"templatePath": "Template.xml",
|
||||
"operation": "modify-parameter",
|
||||
"value": "Период [Новый период]"
|
||||
},
|
||||
"idempotent": true
|
||||
}
|
||||
@@ -42,7 +42,7 @@
|
||||
</dataSet>
|
||||
<calculatedField>
|
||||
<dataPath>Служебное</dataPath>
|
||||
<expression>""</expression>
|
||||
<expression>""</expression>
|
||||
<useRestriction>
|
||||
<condition>true</condition>
|
||||
<order>true</order>
|
||||
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DataCompositionSchema xmlns="http://v8.1c.ru/8.1/data-composition-system/schema"
|
||||
xmlns:dcscom="http://v8.1c.ru/8.1/data-composition-system/common"
|
||||
xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core"
|
||||
xmlns:dcsset="http://v8.1c.ru/8.1/data-composition-system/settings"
|
||||
xmlns:v8="http://v8.1c.ru/8.1/data/core"
|
||||
xmlns:v8ui="http://v8.1c.ru/8.1/data/ui"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<dataSource>
|
||||
<name>ИсточникДанных1</name>
|
||||
<dataSourceType>Local</dataSourceType>
|
||||
</dataSource>
|
||||
<dataSet xsi:type="DataSetQuery">
|
||||
<name>DS</name>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>П</dataPath>
|
||||
<field>П</field>
|
||||
</field>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>Имя</dataPath>
|
||||
<field>Имя</field>
|
||||
</field>
|
||||
<dataSource>ИсточникДанных1</dataSource>
|
||||
<query>ВЫБРАТЬ
|
||||
1 КАК П,
|
||||
"literal" КАК Имя</query>
|
||||
</dataSet>
|
||||
<parameter>
|
||||
<name>Период</name>
|
||||
<title xsi:type="v8:LocalStringType">
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Новый период</v8:content>
|
||||
</v8:item>
|
||||
</title>
|
||||
<valueType>
|
||||
<v8:Type>xs:dateTime</v8:Type>
|
||||
<v8:DateQualifiers>
|
||||
<v8:DateFractions>DateTime</v8:DateFractions>
|
||||
</v8:DateQualifiers>
|
||||
</valueType>
|
||||
</parameter>
|
||||
<settingsVariant>
|
||||
<dcsset:name>Основной</dcsset:name>
|
||||
<dcsset:presentation xsi:type="v8:LocalStringType">
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Основной</v8:content>
|
||||
</v8:item>
|
||||
</dcsset:presentation>
|
||||
<dcsset:settings xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows">
|
||||
<dcsset:selection>
|
||||
</dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:StructureItemGroup">
|
||||
<dcsset:order>
|
||||
<dcsset:item xsi:type="dcsset:OrderItemAuto"/>
|
||||
</dcsset:order>
|
||||
<dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemAuto"/>
|
||||
</dcsset:selection>
|
||||
</dcsset:item>
|
||||
</dcsset:settings>
|
||||
</settingsVariant>
|
||||
</DataCompositionSchema>
|
||||
Reference in New Issue
Block a user