-
Notifications
You must be signed in to change notification settings - Fork 238
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
Disable trim_text
in Deserializer from_reader
#285
Comments
Is there a way to determine whether set trim_text by looking if there is xml:space = "preserve"?
The trailing space here should not be trimmed. |
There are very little customization on the serde deserializer so far. I don't think there is any major blocking point, someone just needs to write it. |
In the coming release Processing of |
Was this implemented already? |
Yes, this is oversight. So, currently this is still not possible, even in |
According to the original use case -- I do not think that simply disabling |
Yeah, that's exactly what happened. I didn't get why that option, even though internal, exists. |
The trimming of spaces within elements probably ought to be separated from the trimming of spaces between elements. It should be possible (and probably the default) to ignore the latter without affecting the text contents of elements themselves. Having an option for trimming spaces around text contents is nice of course, but not at all necessary (the user could easily do this themselves) and as this issue points out it is more difficult to do "correctly" than originally envisioned. Maybe we should eliminate this feature and just keep the "ignore spaces between XML elements" functionality? |
Yes, I think, we should move in that direction. A couple of thoughts:
|
Hello, little update here, since |
Just disabling Well, I think, that we could add a |
I've just created a #572. When it would be merged, we could change the content of an introduced struct Text<'a> {
/// Untrimmed text after concatenating content of all
/// [`Text`] and [`CData`] events
text: Cow<'a, str>,
/// A range into `text` which contains data after trimming
content: Range<usize>,
} Such a change will open a door to use a per-field control for trimming |
Are you still looking at fixing this? If not, what remains to be done? This is a breaking issue for my team, and we may be interested in contributing in order to help fix it. |
I did not put my efforts in this issue since my last comment. Because #572 was merged, we can move forward by the way outlined in that comment. We also can add a way to globally disable trimming, but I think such setting will have a limited usefulness. If you wish feel free to explore those opportunities. |
Is there a easy way to set trim_text to false in the
Deserializer::from_str
when i usequick_xml::de::from_str
?quick-xml/src/de/mod.rs
Lines 160 to 167 in a4be484
The text was updated successfully, but these errors were encountered: