Cxsd
Streaming XSD parser and XML parser generator with TypeScript output
Install / Use
/learn @charto/CxsdREADME
cxsd

cxsd is a streaming XSD parser and XML parser generator for Node.js and
(optionally but highly recommended) TypeScript.
It automatically downloads all referenced .xsd files and outputs two files for each defined namespace:
.jsJavaScript code for Node.js containing a compact state machine table for the cxml parser..d.tsTypeScript definition with JSDoc comments to help editors with tab completion, type verification and tooltips.
Since namespaces map to source files, compiled namespaces can import others like normal JavaScript files.
cxml itself is highly advanced and unlike other JavaScript XML parsers. It fully supports namespaces, derived types and (soon) substitution groups. Output structure is defined mainly by schema, not the XML input. You can correctly parse files with completely unexpected structures (conditions apply) and element names, if they refer to a schema mapping the contents to supported equivalents.
Usage
echo '{ "scripts": { "cxsd": "cxsd" } }' > package.json
npm install cxsd
npm run cxsd http://schemas.opengis.net/wfs/1.1.0/wfs.xsd
The first line just sets up NPM to allow calling cxsd without installing it globally. It also works on Windows if you omit the single quotes (').
This downloads 96 .xsd files (total about 720 kilobytes) and produces 9 .js files for the XML parser (total about 90 kilobytes)
and 9 .d.ts files (total about 480 kilobytes) for TypeScript editors to statically verify the parser output is correctly used and generally help the programmer.
You can import the resulting .d.ts and .js files from TypeScript:
import * as wfs from './xmlns/www.opengis.net/wfs';
import * as ows from './xmlns/www.opengis.net/ows';
var metadata = wfs.document.WFS_Capabilities.OperationsMetadata;
See how the Atom editor with atom-typescript understands the code in the screenshot at the top.
Features
- Automatically download and cache to disk all imported .xsd files
- Convert XSD contents to ES6 equivalents (generated
.jsfiles callcxmlto parse themselves into JavaScript structures)- Types to classes
- Deriving from other types to inheriting other classes
- Imports from remote URLs to imports from local relative paths
- Strings, numbers and dates to matching primitive types
- Lists to arrays
- Types to classes
- To TypeScript equivalents (defined in
.d.tsfor working with source code)- Annotations to JSDoc comments
- Enumerations to unions of string literals
Related projects
- CodeSynthesis XSD generates
C++-based parsers out of XSD schema definitions.
License
Copyright (c) 2015-2016 BusFaster Ltd
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
342.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
