-
Notifications
You must be signed in to change notification settings - Fork 242
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
Add ability to get spans of deserialized values #695
Comments
Currently this is not implemented and it is already tracked in #313. Contributions are welcomed! |
#313 is about lines of code for deserialization errors, this is about lines of code for successful deserializations - even if quick-xml successfully parses e.g. a string attribute, I must be able to raise an error if the string is unexpected |
That's generally impossible without changes in serde, because you cannot get any meta-information from the deserializer generically. Actually, I tried to implement this but that required changes in serde and I outlined the solution here: serde-rs/serde#2420 (comment). I do not see any good solutions here. If you could implement one, make a PR. |
serialize
feature
I have found https://github.com/toml-rs/toml/blob/main/crates/serde_spanned/src/spanned.rs but I don't know enough about the serde ecosystem to give you a concise summary how it works, or whether their approach is feasible for quick-xml. Bugs with certain scenarios do appear to exist though. |
In one of my projects I have to parse and strictly validate XML input coming from other programs and humans, and the latter (understandably) insist on getting decent error messages (e.g. "at 'position' attribute X references an object called 'Y' which is not defined anywhere", "unexpected child Z at 'position', allowed child items are A,B and C").
As of now I use roxmltree and codespan-reporting, but I'd love to switch to an xml library with derivation support - you can imagine a lot of code could be substituted with just using quick-xml.
To satisfy the "nice error messages" requirement I need the precise locations of everything, though. I have scrolled through the deserialization docs, but could not find any mention of access to positions when using deserialization. Did I miss anything or is this not possible right now? Could you expose the offset in the input through e.g. generated getters?
The text was updated successfully, but these errors were encountered: