charto / cxsd

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

Example test for bug in handling targetNamespace ending in # #18

Closed ariutta closed 7 years ago

ariutta commented 7 years ago

csxd and cxml look pretty cool!

I'm getting Error: Cannot find module '../../www.biopax.org/release/biopax-level3.owl'. I think that the library inconsistently handles every XSD with a targetNamespace that ends in #. For the .js and .d.ts file names, the library replaces # with _, but for the module name, it just removes the #, replacing it with nothing. I added a sample test case in this pull request, and you can try it by disabling this workaround.

Here's what's happening in the test case. I run cxsd on this XSD file. That file imports another XSD file with this targetNamespace that ends in #. When I run cxsd, I get module ./xmlns/pathvisio.org/GPML/2013a, as imported here, and that module has dependency var bp = require('../../www.biopax.org/release/biopax-level3.owl'); (without _), but cxsd creates files with the names ./xmlns/www.biopax.org/release/biopax-level3.owl_.js and ./xmlns/www.biopax.org/release/biopax-level3.owl_.d.ts (with _).

The preinstall and postinstall steps in package.json were needed just to get the versions of cget and cxml that the develop branch of cxsd depends on (they haven't been published to npm yet).