Features
With TypesXML you get:
- DOM builder (
DOMBuilder) that preserves lexical information for canonicalization.
- Streaming SAX parser with file, string, and Node.js stream entry points.
- Complete DTD parser and validator supporting parameter entities and conditional sections.
- Default attribute extraction from DTD, Relax NG, or XML Schema grammars.
- OASIS XML Catalog resolver for public and system identifiers.
- Full pass rate on the official W3C XML Conformance Test Suite for DTD grammars.
- Canonical XML renderer aligned with W3C XML Test Suite rules.
- Strict XML 1.0/1.1 character validation with optional DTD-validating mode.
- Pure TypeScript implementation ready for ESM and CommonJS bundlers.
TypesXML stays strictly compatible with open XML standards, keeping your pipelines portable across
tooling ecosystems.
Resources and Assurance
Documentation & Samples
- Step-by-step tutorial for onboarding.
- Runnable samples covering common workflows.
- Up-to-date README with API notes and release history.
- NPM distribution with TypeScript definitions included.
Quality & Compatibility
- Automated harness for the W3C XML Conformance Test Suite.
- Canonical XML renderer compatible with W3C expectations.
- Strict XML 1.0/1.1 character validation across parsing modes.
- Deterministic builds from a pure TypeScript codebase—no native dependencies required.
TypeScript/JavaScript Applications
Drop TypesXML into any Node.js or browser pipeline:
import { DOMBuilder, SAXParser } from "typesxml";
const handler = new DOMBuilder();
const parser = new SAXParser();
parser.setContentHandler(handler);
// Parse from a file
parser.parseFile("example.xml");
const document = handler.getDocument();
console.log(document.toString());
// Parse from a string
parser.parseString('<root><child/></root>');
// Parse from a stream
// await parser.parseStream(fs.createReadStream("example.xml"));
Validation & Catalog Configuration
Enable strict validation and wire in XML Catalog resolution before invoking a parse method:
import { Catalog, SAXParser } from "typesxml";
const parser = new SAXParser();
parser.setCatalog(new Catalog("/path/to/catalog.xml"));
parser.setValidating(true); // Turns on DTD validation only.
After configuration, invoke any of the parseFile, parseString, or
parseStream helpers to process XML with validation enabled.