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 分