validate_instance
Validate an XML instance against its SDC4 XSD schema. Returns pass or fail with error counts.
schema_path必填instance_path必填reference_path
io.github.SemanticDataCharter由 GitHub 帳號 SemanticDataCharter 發布v4.0.0更新於 Nov 1, 2026
Validate and recover SDC4 Governed Data Records in TypeScript, conforming to sdcvalidator.
在 XML 中驗證並復原 SDC4 受治理資料記錄(Governed Data Records),提供兩層錯誤分類與 ExceptionalValue 復原。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
參照 儲存庫 中的啟動說明。
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.
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.
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.
The conformance suite compares, for every case:
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.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.
SDC4 schemas use a narrow part of XSD 1.1, and this library implements that part:
ref, occurrence, fixed, abstract and substitution groups.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.
Dependencies are pinned exactly: @xmldom/xmldom 0.9.12 (parsing) and fontoxpath 3.34.0
(XPath 3.1, for assertions).
Apache-2.0.
來源:README.md,提交 0e7cb68
Validate an XML instance against its SDC4 XSD schema. Returns pass or fail with error counts.
schema_path必填instance_path必填reference_pathValidate 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_pathRecover 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_pathCheck whether an XSD schema follows SDC4 principles (restriction only, no xsd:extension). Does not validate instances.
schema_path必填已滿足適用檢查項的 90%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
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.npx sdcvalidator-ts mcpnpm installnpm run typechecknpm test # needs the conformance suite: a sibling sdcvalidator checkout, or CONFORMANCE_DIRnpm run build