Closed Shohaii closed 6 months ago
@Shohaii Thank you for your report.
If I understand correctly, you want a feature that an enum type that can have variants from child
type or text
type, right?
like:
pub enum TestEnum {
#[xmlserde(ty="text")]
V1(string)
#[xmlserde(ty="child")]
V2(StructA)
}
I think this is a good idea. I would like to add a feature like that.
@ImJeremyHe Thank you for your quick reply. Yes, your suggestion looks great.
I hope that then, the implementation like this:
#[derive(Debug, XmlSerialize, XmlDeserialize)]
pub struct TextP {
#[xmlserde(ty = "untag")]
pub text_p_content: Vec<TextPContent>,
}
#[derive(Debug, XmlSerialize, XmlDeserialize)]
pub enum TextPContent {
#[xmlserde(ty = "text")]
Text(String),
#[xmlserde(name = b"text:span", ty = "child")]
TextSpan(TextSpan),
}
would solve all my issues.
<text:p text:style-name="P5"/>
caseor maybe you can think of a better way. Anyway something like this would be great.
Thank you for your time.
I will work on this later. Thanks for your confirmation
@Shohaii Please have a look at this unit test.
Hi @ImJeremyHe, the feature works great. thank you. Long live the crate.
Hi Jeremy, thanks for great crate.
I am trying to deserialize following xml:
Yes, I know, it has nothing in common with LogiSheets, but your crate works almost perfectly even for ODT file.
The problem is with preparation of rust structs and enums for deserialization of:
<text:p>
- can have a children or can have a text or none of it<text:span>
- can have a children<office:annotation>
,<office:annotation-end>
,<text:s/>
and textI tried to implement it like this (ignoring attributes):
Unfortunately, this is not compilable, but I wonder if there is a way, how to make it work with xmlserde crate. Sorry if I made some silly mistake in code, I am new to Rust.
There might be 3 options how to make it work:
I would like to know your opinion, thanks.