• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Streaming XSD parser and XML parser generator with TypeScript output

cxsd

build status dependency status npm version

Atom screenshot

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:

  • .js JavaScript code for Node.js containing a compact state machine table for the cxml parser.
  • .d.ts TypeScript 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 .js files call cxml to 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
  • To TypeScript equivalents (defined in .d.ts for working with source code)
    • Annotations to JSDoc comments
    • Enumerations to unions of string literals

Related projects

License

The MIT License

Copyright (c) 2015-2016 BusFaster Ltd

More Repositories

1

nbind

✨ Magical headers that make your C++ library accessible from JavaScript 🚀
C++
1,980
star
2

cwait

⌛ Limit number of promises running in parallel
TypeScript
199
star
3

classy-mst

ES6-like syntax for mobx-state-tree
TypeScript
91
star
4

bigfloat

Fast arbitrary precision math library for computational geometry.
TypeScript
76
star
5

phosphor-float-area

✊ Draggable ⚓ Dockable ↔️ Resizable ⛵ Floating 📑 Tabbed HTML5 dialogs! 🎉
TypeScript
72
star
6

cxml

Advanced schema-aware streaming XML parser
TypeScript
44
star
7

cbuild

Use SystemJS with npm instead of jspm
TypeScript
25
star
8

docts

README.md API section autogenerator for TypeScript projects
TypeScript
22
star
9

autogypi

Autogypi handles dependencies for node-gyp projects.
TypeScript
21
star
10

readts

TypeScript exported definitions parser
TypeScript
19
star
11

nbind-example-universal

Example of compiling C++ to asm.js and Node.js addons
TypeScript
14
star
12

example-typescript-npm

Example of a TypeScript-based npm package
TypeScript
12
star
13

autodts

DEPRECATED (TypeScript 1.8 includes all functionality)
JavaScript
6
star
14

Taming-Polymer-with-SystemJS-and-TypeScript-part-1

HTML
6
star
15

nbind-examples

Examples of connecting C++ and JavaScript with nbind
C++
4
star
16

fracts

JavaScript
4
star
17

emscripten-library-decorator

Decorators for writing Emscripten libraries
TypeScript
3
star
18

blog-setup

HTML
2
star
19

geo-types

Data types for map and GIS applications
TypeScript
2
star
20

poc-map

Proof of concept automatic map visualizer
TypeScript
2
star
21

cget

Robust streaming cache for HTTP requests
TypeScript
1
star
22

cresolve

Node-style module resolution for SystemJS
TypeScript
1
star
23

annotype

Generate Closure Compiler annotations from TypeScript source
TypeScript
1
star
24

charto-polymer-shim

JavaScript
1
star
25

example-typescript-dependency

Another example of a TypeScript-based package
TypeScript
1
star
26

wxs-feed

WFS / WMS server (VERY ALPHA)
TypeScript
1
star
27

ts-git

Compact high-level JavaScript API for git
TypeScript
1
star
28

nbind-example-minimal

C++
1
star
29

charto-vue

Vue.ts + TypeScript + SystemJS project template
JavaScript
1
star