Sdcvalidator Ts

io.github.SemanticDataCharter由 GitHub 账号 SemanticDataCharter 发布v4.0.0更新于 Nov 1, 2026

Validate and recover SDC4 Governed Data Records in TypeScript, conforming to sdcvalidator.

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

在 XML 中校验并恢复 SDC4 受治理数据记录(Governed Data Records),提供两级错误分类与 ExceptionalValue 恢复。

可以做什么
  • 按 SDC4 XSD 模型校验 XML 实例,返回通过或失败及错误数量
  • 逐条报告错误,包括路径、层级(结构或语义)、未通过的约束和 ExceptionalValue 代码
  • 恢复记录:为语义错误的值标注 ISO 21090 ExceptionalValue 代码,含结构错误的记录会被拒绝
  • 检查 XSD 架构是否符合 SDC4 原则,即只允许 restriction、不允许 extension
适用场景
适合处理 SDC4 受治理数据记录的场景:需要按已发布模型校验实例、解释校验错误,或生成带 ExceptionalValue 标注的恢复记录时使用。
运行要求
通过 npx 以 stdio 在本地运行,需要 Node.js 20 或更高版本。工具接收 schema_path 与 instance_path,可选 reference_path。未提供 reference_path 时,会从架构所包含参考模型的 URL 获取一次并缓存;提供本地副本即可离线使用。
安装前请注意
服务器会读取你指定的文件,请只传入你愿意暴露的路径。未提供 reference_path 时会发起网络请求获取被包含的参考模型。恢复会改写返回记录中的值,使用前请检查恢复结果。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Sdcvalidator Ts,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

sdcvalidator-ts

SDC4 validation in TypeScript. It validates Governed Data Records against their published SDC4 models and recovers semantic errors with ISO 21090 ExceptionalValues, giving the same results as sdcvalidator, the reference implementation, on its conformance suite.

Conforms to: sdcvalidator 4.6.3 (all 151 cases of its conformance suite). CI runs that release's suite, pinned by tag.

It runs in Node (20 or later), Deno (including Supabase Edge Functions) and browsers. You supply the model and record text, so it reads no files and makes no network requests.

ts
import { SDC4Validator, REFERENCE_MODEL_URL } from 'sdcvalidator-ts';
const validator = new SDC4Validator({  text: modelXsd,                       // the model's published XSD  resolve: (location) => sdc4Xsd,       // the reference model it includes (REFERENCE_MODEL_URL)});
const result = validator.validate(recordXml);// { valid, structural: [...], semantic: [{ path, ev, kind, constraint, message }, ...] }
const recovered = validator.recover(recordXml);// { ok, recoveries: [{ path, code, name, inserted }], unrecoverable: [...], record, text }// Throws StructuralValidationError if the record has structural errors.

MCP server

The package includes an MCP server, so agents can call it directly. It speaks JSON-RPC 2.0 over stdio and runs on Node; it reads the files you name.

bash
npx sdcvalidator-ts mcp
ToolWhat it does
validate_instancePass or fail, with error counts
validate_and_reportEvery error: path, tier, the constraint that failed, the ExceptionalValue code
recover_instanceThe recovered record and each value covered; a structural error rejects it
check_schema_complianceWhether a schema follows SDC4 principles: restriction, never extension

Each tool takes schema_path and instance_path (except the compliance check, which takes only the schema), plus an optional reference_path. The model's xsd:include of the reference model is fetched from its URL once and cached. With reference_path, it is read from that local copy instead, so the server works offline.

It is registered in the MCP registry as io.github.SemanticDataCharter/sdcvalidator-ts.

What "the same results" means

The conformance suite compares, for every case:

  • the verdict;
  • structural and semantic errors by path;
  • the ExceptionalValue code for each semantic error;
  • the recovery outcome;
  • the recovered record, compared as a tree with comments ignored.

Error messages are not compared. Errors are classified by the constraint that failed, never by message wording.

The ExceptionalValue codes are the reference's (sdcvalidator 4.6.3):

  • OTH: a value outside its enumeration.
  • INV: a value that is not of its type, or that breaks any other facet (pattern, length, range, digits, a built-in type's own range), a fixed value or an assertion.
  • NA: character data where only elements are allowed.
  • No code: an error on a structural element (label, vtb, vte, ...). It cannot be recovered.

When sdcvalidator's mapping changes, the suite's expectations change, and this library follows before its next release.

The XSD subset

SDC4 schemas use a narrow part of XSD 1.1, and this library implements that part:

  • Elements: global and local, with ref, occurrence, fixed, abstract and substitution groups.
  • Complex types: complex and simple content, restriction and extension, sequence and choice.
  • Simple types: restriction (with the enumeration, pattern, length, range, digits and whiteSpace facets) and list; about forty built-in types.
  • xsd:assert: evaluated with fontoxpath, inherited by derived types.
  • xsd:include.

A construct outside the subset raises UnsupportedSchemaError naming it. It is never ignored.

DOCTYPE and entity declarations are refused before parsing, so no external entity is ever resolved.

Development

bash
npm installnpm run typechecknpm test     # needs the conformance suite: a sibling sdcvalidator checkout, or CONFORMANCE_DIRnpm run build

Dependencies are pinned exactly: @xmldom/xmldom 0.9.12 (parsing) and fontoxpath 3.34.0 (XPath 3.1, for assertions).

License

Apache-2.0.

来源:README.md,提交 0e7cb68

工具

4

validate_instance

Validate an XML instance against its SDC4 XSD schema. Returns pass or fail with error counts.

输入参数schema_path必填instance_path必填reference_path

validate_and_report

Validate an XML instance and report every error: its path, its tier (structural or semantic), the constraint that failed, and the ExceptionalValue code recovery would use.

输入参数schema_path必填instance_path必填reference_path

recover_instance

Recover an XML instance: each value with a semantic error keeps its value and is tagged with an ISO 21090 ExceptionalValue. Returns the recovered record and each value covered; a record with structural errors is rejected.

输入参数schema_path必填instance_path必填reference_path

check_schema_compliance

Check whether an XSD schema follows SDC4 principles (restriction only, no xsd:extension). Does not validate instances.

输入参数schema_path必填

版本历史

1
  1. v4.0.0最新Nov 1, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分