-
Notifications
You must be signed in to change notification settings - Fork 18
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
Parser doesn't support whitespace before prolog #248
Comments
As far as I can tell leading whitespace is not allowed before the prolog according to the specifications.
|
That's fair but it's tolerated by many readers/engines consuming XML. |
Related issues:
I think it would make sense to only show a syntax error in that case but be fault tolerant, meaning This may depend on: Chevrotain/chevrotain#646 |
I'd suggest that at least recovering from the error would be nice. |
A full productive solution in this library would also have to deal with creating the syntax error and perhaps even making However, you may be able to accomplish this yourself by extending the XMLParser class and overriding the However, Grammar inheritance is a little tricky with Chevrotain, so I'm not sure you can use it without first making some small changes to the XMLParser itself. Another option could be to create a subclass with a new grammar rule entry point $.RULE("documentWithMiscPrefix", () => {
$.MANY(() => {
$.SUBRULE($.misc);
});
// continue parsing using the original logic
$.SUBRULE($.document); This may bypass some of the grammar inheritance issues, but I am not 100% sure. To make this XMLParser easily extensible you would need to enable deferring the performSelfAnalysis call at the end of the constructor.
Perhaps this is the most time efficient solution, As I personally don't know when I will get around to implementing a "proper" solution to this issue, however you could pretty easily contribute a PR making the XMLParser more extensible and then |
Thanks for the pointers. Though I'd love to contribute, this is a bit over our bandwidth right now; this is for another OSS project where switching to this parser is already a major effort 😄 We'll see if it harms our users in practice. |
The parser fails completely, and without errors, when there is whitespace before the XML prolog.
I need to preserve positions so I can't trim those spaces; it should be possible to allow them.
The text was updated successfully, but these errors were encountered: