Releases: harshanacz/xerces-wasm-validator
Releases · harshanacz/xerces-wasm-validator
Release list
2.0.2
Documentation: rewritten README with an API reference, restructured sections, and a corrected memory comparison in the benchmark table.
Full changelog: https://github.com/harshanacz/xerces-wasm-validator/blob/main/CHANGELOG.md
v2.0.0 — Full rewrite: cached grammar pools
⚠️ Breaking release. v2 is a complete rewrite with a new architecture and API. v1.x code will not work unchanged — see Migration below.
Highlights
- In-memory grammar pool caching — each project's XSDs compile once into a locked
XMLGrammarPoolheld in WASM memory; every validation reuses it, no re-parsing. - New project-based API —
createProjectValidator()returns a reusable validator withvalidate(),reload(), anddestroy(). - Per-project isolation — each project keeps its own compiled pool, so the same XML can be valid in one project and invalid in another.
- Fast re-validation — in the bundled benchmark: ~22 ms one-time compile, ~0.04 ms per subsequent
validate(). - Node.js + browser — the same WASM module runs in both.
New API
import { createProjectValidator } from "xerces-wasm";
const v = await createProjectValidator({
entry: "main.xsd",
files: { "main.xsd": xsdText /*, "types.xsd": ... */ },
});
const { valid, parseErrors, schemaErrors } = await v.validate(xml);
await v.reload(updatedFiles); // recompile when schemas change
v.destroy(); // free the pool from WASM memoryEvery validate() runs two passes: syntax (well-formedness → parseErrors) and schema (XSD rules → schemaErrors). Diagnostics are { message, line, column, severity }.
Breaking changes
- Validation now goes through a
createProjectValidator()instance, not a one-shot top-level call. - Results are
{ valid, parseErrors, schemaErrors }(separate syntax vs. schema error lists). - You must call
destroy()when done — WASM memory is not reclaimed by the JS garbage collector.
Migration from v1.x
- Create one validator per project with
createProjectValidator({ entry, files }). - Pass every dependent XSD in
files(keyed by filename) soxs:import/xs:includeresolve from memory. - Read results from
parseErrors/schemaErrorsinstead of the old result shape. - Call
destroy()when a project closes.
Install
npm install xerces-wasm@2.0.0License
MIT. Bundles Apache Xerces-C++ (Apache-2.0) — see LICENSE-APACHE and NOTICE.