Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cxml in browser #5

Open
sunnyawake5 opened this issue Sep 19, 2016 · 3 comments
Open

use cxml in browser #5

sunnyawake5 opened this issue Sep 19, 2016 · 3 comments

Comments

@sunnyawake5
Copy link

can cxml used in browser env?

thanks.

@jjrv
Copy link
Member

jjrv commented Feb 10, 2017

Support should be coming this year, but it may still be some months away with so many ongoing projects. It will use the browser's native XML parsing, and process the result to use JavaScript objects matching the schema: if the schema allows several child elements of the same type, then even a single such child will be in an array, and placeholders will be added to the object prototypes for required elements so you code can rely on them being present.

@owennewo
Copy link

I've just started using cxml in an angular4/typescript app. It works. Took me a while to get it working - the system-config.ts requires a long list of map and packages declaration to get the dependent modules loaded. I expect there was an easier way but I'm new to javascript module loading.

My browser loads the angular4 app from node/lite-server then it loads a remote musicxml file and then uses cxml.parser.parse(xml, musicxml.document). The musicxml.document was created using cxsd.

@jjrv - does the work you are intending to do mean that you won't have so many node dependencies?

@jjrv
Copy link
Member

jjrv commented Mar 30, 2017

@owennewo Congratulations on getting it working!

Currently I'm working on the rewrite branch, a much faster implementation with nbind as the only dependency. The XML parser core will be a native binary on Node.js. It's mostly ready now. A precompiled asm.js version with no dependencies will be provided in case a C++ compiler is not installed. I expect the native binary version to be overall the fastest XML parser available for JavaScript.

I'll do some testing but it seems likely to outperform using the browser's native parsing, since the browser creates a DOM tree that then gets thrown away. If the browsers' own parser runs faster after all, I'll use that.

Current master branch of cxml depends on sax which uses Node.js internal libraries that need shims for browsers as provided by SystemJS, Browserify and such. I'll get rid of that library to avoid the issue.

Ultimately a single .js file will be provided for browsers, so it can be simply included with a script tag if not using any JS loader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants