Registry / testing / xsd-schema-validator

xsd-schema-validator

JSON →
library0.11.0jsnpmunverified

A Node.js library for validating XML against XSD schemas, using Java under the hood. Current stable version is 0.11.0, with infrequent releases. It wraps Java's built-in XML validation capabilities, making it a reliable choice when Java is available. Key differentiators: it works with strings, streams, or file paths; returns a promise with a result object. Note: it depends on a local Java installation (JDK or JRE) and the 'javac'/'java' commands. The library is ESM-only since version 0.11.0 and ships TypeScript types. It is actively maintained but has limited community adoption.

npm install xsd-schema-validator
INSTALL
IMPORT
SIG · XSD-SCHEMA-VALIDAT
X
xsd-schema-validator
testingjavascriptv0.11.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

validateXML
import { validateXML } from 'xsd-schema-validator'
const { validateXML } = require('xsd-schema-validator')
ESM-only since v0.11.0; CJS require() may fail if the package does not export a CommonJS module.
default
import validator from 'xsd-schema-validator'
const validator = require('xsd-schema-validator')
Default export is the validator module; you can use either default or named import.
validateXML (type)
import type { ValidateXMLOptions, ValidationResult } from 'xsd-schema-validator'
TypeScript types are included; no wrong pattern typically for type imports.

Shows how to validate an XML string against an XSD schema file using async/await and import syntax.

import { validateXML } from 'xsd-schema-validator'; const xmlStr = '<foo:bar xmlns:foo="http://example.com"/>'; const xsdPath = 'schema.xsd'; try { const result = await validateXML(xmlStr, xsdPath); console.log('Valid:', result.valid); } catch (err) { console.error('Validation failed:', err.message); }
Debug
Known issues
breakingPackage is ESM-only since v0.11.0; CommonJS require() will fail.
fix
Use import syntax or dynamic import().
affects: >=0.11.0
gotchaRequires Java (JDK or JRE) to be installed and 'javac'/'java' on PATH; otherwise validation will fail.
fix
Install Java (e.g., OpenJDK 11+) and set JAVA_HOME if needed.
affects: >=0.0.0
gotchaXSD files must be local file paths; remote URLs or non-file paths are not supported.
fix
Download remote schemas to a local file before validating.
affects: >=0.0.0
breakingRemoved support for Node.js < 18 in v0.11.0.
fix
Upgrade Node.js to 18 or later.
affects: >=0.11.0
deprecatedCallback-based API removed; only async/await is supported.
fix
Use async/await with try/catch.
affects: >=0.11.0
Errors
Common errors & fixes
Error: spawn javac ENOENT
Java compiler not found on system PATH or JAVA_HOME not set.
fix
Install Java JDK and ensure 'javac' is accessible in your terminal.
TypeError: validator.validateXML is not a function
Using CommonJS require() with ESM-only package version.
fix
Use ES module import syntax: import { validateXML } from 'xsd-schema-validator'
Error: Unsupported identifier: /path/to/remote.xsd (not a file)
Providing a URL or non-file path to the XSD schema argument.
fix
Download the schema to a local file and use the file path.
Error: Cannot find module 'xsd-schema-validator'
Package not installed or not in node_modules.
fix
Run 'npm install xsd-schema-validator'
SyntaxError: Unexpected token 'export'
Running older Node.js that does not support ES modules.
fix
Upgrade Node.js to 18+ or use a transpiler like Babel.
Upgrade
Version history
0.11.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
37 hits · last 30 days
node
34
Resources
xsd-schema-validator — npm install xsd-schema-validator · libregistry