{"id":49798,"library":"xsd-validator","title":"xsd-validator","description":"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.","status":"active","version":"1.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/deltazero-cz/node-xsd-validator","tags":["javascript","XSD","XML","Schema","Schema Validation","Schema Validator","XSD Schema","XSD Schema Validation","XSD Schema Validator","typescript"],"install":[{"cmd":"npm install xsd-validator","lang":"bash","label":"npm"},{"cmd":"yarn add xsd-validator","lang":"bash","label":"yarn"},{"cmd":"pnpm add xsd-validator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Binds to libxml2 for parsing and schema validation","package":"libxmljs","optional":false}],"imports":[{"note":"Default ESM export; named imports not supported.","wrong":"const validateSchema = require('xsd-validator')","symbol":"validateSchema","correct":"import validateSchema from 'xsd-validator'"},{"note":"The library exports a single default function.","wrong":"import { validateSchema } from 'xsd-validator'","symbol":"validateSchema (TypeScript)","correct":"import validateSchema from 'xsd-validator'"},{"note":"In CommonJS, default export is under .default property.","wrong":"const validateSchema = require('xsd-validator')","symbol":"validateSchema (CommonJS)","correct":"const validateSchema = require('xsd-validator').default"}],"quickstart":{"code":"import validateSchema from 'xsd-validator';\n\nconst xml = `<?xml version=\"1.0\"?>\n<person>\n  <name>John Doe</name>\n</person>`;\n\nconst xsd = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n  <xs:element name=\"person\">\n    <xs:complexType>\n      <xs:sequence>\n        <xs:element name=\"name\" type=\"xs:string\"/>\n      </xs:sequence>\n    </xs:complexType>\n  </xs:element>\n</xs:schema>`;\n\nconst result = validateSchema(xml, xsd);\nif (result === true) {\n  console.log('XML is valid.');\n} else {\n  console.log('Validation errors:', result);\n}","lang":"typescript","description":"Validates an XML document against an XSD schema, handling both valid and invalid cases."},"warnings":[{"fix":"Install build tools: on Ubuntu: build-essential; on macOS: Xcode CLI tools; on Windows: npm install --global windows-build-tools","message":"libxmljs native compilation requires build tools (C++ compiler, make). On Windows, may need windows-build-tools.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure libxml2-dev (Ubuntu) or equivalent is installed. Alternatively, use a prebuilt binary via node-pre-gyp.","message":"The library may fail to load if libxml2 is not installed or version mismatched on the system.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Handle result as either true or an array of objects with 'message', 'domain', etc.","message":"Error objects returned for invalid XML are native libxmljs error arrays, not standard Error instances.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Node.js to >=14.0.0","message":"Node.js versions below 14 are no longer supported.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.1':20 'altern':77 'api':38,91 'array':46 'beyond':55 'bind':30 'boolean':40 'cadenc':67 'class':60 'configur':94 'current':23 'depend':54 'differenti':36 'direct':83 'document':15,43 'driven':72 'e.g':78 'error':45 'extern':51 'first':59 'first-class':58 'focus':87 'invalid':48 'javascript':95 'key':35 'librari':11 'libxml2':29,56 'libxmlj':28,74,82 'lightweight':9 'low':69 'mainten':70 'node.js':10 'offer':85 'one':49 'parser':53 'perform':32 'releas':25,66 'return':39 'schema':18,33,98,99,101,104,106,109 'ship':64 'simpl':37 'stabl':24 'support':62 'type':65 'typescript':61,111 'unlik':76 'updat':75 'valid':3,6,13,34,42,81,89,100,102,107,110 'validation-on':88 'version':19 'wrap':27 'xml':14,52,80,97 'xml-valid':79 'xsd':2,5,17,96,103,105,108 'xsd-valid':1,4 'zero':93","created_at":"2026-06-07T17:03:39.584135+00:00","updated_at":"2026-06-07T17:03:39.584135+00:00","problems":[{"fix":"Set \"type\": \"module\" in package.json or use .mjs extension.","cause":"Using ESM syntax in a CommonJS project without proper configuration.","error":"Error: Module parse failed: The keyword 'import' is reserved"},{"fix":"Use const validateSchema = require('xsd-validator').default","cause":"Using CommonJS require without accessing .default property.","error":"TypeError: validateSchema is not a function"},{"fix":"Run 'npm rebuild libxmljs' or 'npm install' again with build tools installed.","cause":"Missing libxmljs native binding; may need recompilation.","error":"Error: libxmljs.node: No such file or directory"},{"fix":"Ensure the XML and XSD have matching target namespaces or xmlns declarations.","cause":"XML root element does not match the schema's target namespace.","error":"ValidationError: Element '...': No matching global declaration available for the validation root."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/deltazero-cz/node-xsd-validator#readme","github":"https://github.com/deltazero-cz/node-xsd-validator","docs":null,"changelog":null,"pypi":null,"npm":"xsd-validator","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}