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

Error when parsing a field which was not present in the xsd file #14

Open
davidspiess opened this issue May 4, 2018 · 5 comments
Open

Comments

@davidspiess
Copy link

davidspiess commented May 4, 2018

If the parser (v.0.1.1) encounters a field which is not part of the xsd, it throws the following error

Unhandled rejection TypeError: Cannot read property 'proxy' of undefined
    at SAXStream.<anonymous> (/app/node_modules/cxml/dist/xml/Parser.js:160:24)
    at emitOne (events.js:116:13)
    at SAXStream.emit (events.js:211:7)
    at SAXParser.me._parser.(anonymous function) [as onclosetag] (/app/node_modules/sax/lib/sax.js:258:17)
    at emit (/app/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/app/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/app/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/app/node_modules/sax/lib/sax.js:1436:13)
    at SAXStream.write (/app/node_modules/sax/lib/sax.js:239:18)
    at Parser._parse (/app/node_modules/cxml/dist/xml/Parser.js:187:17)
    at /app/node_modules/cxml/dist/xml/Parser.js:53:26
    at Promise._execute (/app/node_modules/bluebird/js/release/debuggability.js:303:9)
    at Promise._resolveFromExecutor (/app/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/app/node_modules/bluebird/js/release/promise.js:79:10)
    at Parser.parse (/app/node_modules/cxml/dist/xml/Parser.js:52:17)
    at Object.<anonymous> (/app/src/index.ts:7:23)

If my xml provider adds a new field to their api my whole application breaks until i regenerate the xsd with cxsd.

@davidspiess
Copy link
Author

I noticed it's not possible to create a pull request for a specific commit or release so i forked the repository and fixed it for my project.

davidspiess@7fad521

@Ottunger
Copy link

@davidspiess Maybe here is not the best place to ask, but since you are using cxsd, do you have any doc on how to use it with cxml?
I've tried to infer how to use them with their TS typings, but so far, no luck.

Thanks!

@davidspiess
Copy link
Author

davidspiess commented May 11, 2018

I used the 0.1.1 version as there is documentation for that
https://github.com/charto/cxml/tree/fce69086cd5f7ec476e0ff87d5a7f44b9879bd69

You have to pass the output of cxsd as second parameter to the parser.

import * as cxsd from 'cxsd/outputfiles';

const parser = new cxml.Parser();
parser.parse('<xml></xml>', cxsd.document);

@Ottunger
Copy link

Thanks a lot :)
Indeed .parse does not exist on the object according to TS.

So you're using a custom cxml, makes sense. Is it a fork of 0.1.1?

@davidspiess
Copy link
Author

Always glad to help! 😄
Yeah i created a fork of 0.1.1 because of the issue which i described above.

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

2 participants