xsd-validator is a lightweight Node.js library for validating XML documents against XSD schemas. Version 1.1.1 is the current stable release. It wraps libxmljs (libxml2 bindings) to perform schema validation. Key differentiators: simple API returning boolean for valid documents and Error arrays for invalid ones, no external XML parser dependency beyond libxml2, and first-class TypeScript support with shipped types. Release cadence is low; maintenance is driven by libxmljs updates. Unlike alternatives (e.g., xml-validator, libxmljs directly), it offers a focused validation-only API with zero configuration.
npm install xsd-validatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Validates an XML document against an XSD schema, handling both valid and invalid cases.
Install build tools: on Ubuntu: build-essential; on macOS: Xcode CLI tools; on Windows: npm install --global windows-build-tools
Ensure libxml2-dev (Ubuntu) or equivalent is installed. Alternatively, use a prebuilt binary via node-pre-gyp.
Handle result as either true or an array of objects with 'message', 'domain', etc.
Upgrade Node.js to >=14.0.0
Set "type": "module" in package.json or use .mjs extension.
Use const validateSchema = require('xsd-validator').defaultRun 'npm rebuild libxmljs' or 'npm install' again with build tools installed.
Ensure the XML and XSD have matching target namespaces or xmlns declarations.