fix(skd-validate): правки по ревью — битая схема и MaxErrors в XSD-проверке

Битый .xsd в каталоге версии давал необработанное исключение (PS — на
чтении схем, py — на построении модели подсказок); теперь в обоих
портах предупреждение «do not compile — not checked». Отложенные
ошибки атрибутов в PS учитывают MaxErrors на каждой строке.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018dc2yLQfw6wppbopM1Y4Ps
This commit is contained in:
Nick Shirokov
2026-09-29 17:38:19 +03:00
co-authored by Claude Opus 5.5
parent 8c15c84f73
commit 21ebd814de
2 changed files with 10 additions and 5 deletions
@@ -1211,10 +1211,13 @@ function Invoke-XsdCheck {
# дописываем элемент в саму схему СКД: вторую схему того же namespace без SourceUri # дописываем элемент в саму схему СКД: вторую схему того же namespace без SourceUri
# XmlSchemaSet молча отбрасывает. # XmlSchemaSet молча отбрасывает.
$schemas = @() $schemas = @()
foreach ($f in Get-ChildItem -LiteralPath $useDir -Filter *.xsd -File) { # Битый .xsd (например, недокачанный) — предупреждение, а не падение навыка
$fs = [System.IO.File]::OpenRead($f.FullName) try {
try { $schemas += [System.Xml.Schema.XmlSchema]::Read($fs, $null) } finally { $fs.Dispose() } foreach ($f in Get-ChildItem -LiteralPath $useDir -Filter *.xsd -File) {
} $fs = [System.IO.File]::OpenRead($f.FullName)
try { $schemas += [System.Xml.Schema.XmlSchema]::Read($fs, $null) } finally { $fs.Dispose() }
}
} catch { Report-Warn "XSD: schemas in '$useDir' do not compile — not checked: $($_.Exception.Message)"; return }
$dcs = $schemas | Where-Object { $_.TargetNamespace -ceq $xsdDcsNs } | Select-Object -First 1 $dcs = $schemas | Where-Object { $_.TargetNamespace -ceq $xsdDcsNs } | Select-Object -First 1
$hasRoot = $false $hasRoot = $false
foreach ($it in $dcs.Items) { foreach ($it in $dcs.Items) {
@@ -1283,6 +1286,7 @@ function Invoke-XsdCheck {
# Имя — в дети родителя (и у пустого элемента: он тоже сосед для подсказки) # Имя — в дети родителя (и у пустого элемента: он тоже сосед для подсказки)
if ($script:xsdStack.Count -gt 0) { [void]$script:xsdStack[$script:xsdStack.Count - 1].children.Add($r.LocalName) } if ($script:xsdStack.Count -gt 0) { [void]$script:xsdStack[$script:xsdStack.Count - 1].children.Add($r.LocalName) }
foreach ($pa in $script:xsdPending) { foreach ($pa in $script:xsdPending) {
if ($script:stopped) { break }
$xt = $r.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance") $xt = $r.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance")
$info = @{ elem = $r.LocalName; parent = $(if ($script:xsdStack.Count -gt 0) { $script:xsdStack[$script:xsdStack.Count - 1].name } else { '' }); xsiNs = ''; xsiLocal = '' } $info = @{ elem = $r.LocalName; parent = $(if ($script:xsdStack.Count -gt 0) { $script:xsdStack[$script:xsdStack.Count - 1].name } else { '' }); xsiNs = ''; xsiLocal = '' }
if ($xt) { if ($xt) {
@@ -1309,11 +1309,12 @@ def xsd_check():
use_ver = cands[0] use_ver = cands[0]
exact = use_ver == ver exact = use_ver == ver
model = xsd_model(os.path.join(xsd_root, use_ver))
tmp = tempfile.mkdtemp(prefix="skd-xsd-") tmp = tempfile.mkdtemp(prefix="skd-xsd-")
try: try:
try: try:
schema = _xsd_build_schema(os.path.join(xsd_root, use_ver), tmp) schema = _xsd_build_schema(os.path.join(xsd_root, use_ver), tmp)
# Модель — после компиляции, как в PS-мастере: битый .xsd даёт предупреждение, а не трейсбэк
model = xsd_model(os.path.join(xsd_root, use_ver))
except Exception as ex: except Exception as ex:
report_warn(f"XSD: schemas in '{os.path.join(xsd_root, use_ver)}' do not compile — not checked: {ex}") report_warn(f"XSD: schemas in '{os.path.join(xsd_root, use_ver)}' do not compile — not checked: {ex}")
return return