charto / cxsd

Streaming XSD parser and XML parser generator with TypeScript output
MIT License
111 stars 55 forks source link

cxsd fails silently with unknown encoding #32

Open machinagod opened 10 months ago

machinagod commented 10 months ago

When running cxsd against a XSD file using a non-supported encoding in libexpat (example here), csxd will fail with the following error:

typeerror: Cannot read properties of undefined (reading 'id')

Supported encodings in libexpat are (from here):

There are four built-in encodings in Expat:

UTF-8 UTF-16 ISO-8859-1 US-ASCII

I believe this is caused by node-expat not supporting the Unknown Encoding parser.

Reencoding the file in UTF-8 or hard setting the parser encoding on the Parser initialization (on my fork, here) allows the parser to properly complete.

Recording this issue as a helper for others suffering the same issue.