Closed RinChanNOWWW closed 1 year ago
PTAL @MarcAntoine-Arnaud
Hello, Sorry for the delay. For namespace, the derive cannot take variable. Some example are provided in the repo, like https://github.com/media-io/yaserde/blob/master/examples/src/bbigras_namespace.rs 2 attributes are important :
Is it clear ?
Best regards
Thanks for answering.
What is the best way to deal with the case if the namespace could change? Make two different structs? Is there a simpler way?
Yes it's the simplest. And using flatten is great to do:
#[derive(YaDeserialize)]
#[yaserde ...]
struct MyNamespace1 {
#[yaserde(flatten)]
fields: Fields
}
#[derive(YaDeserialize)]
#[yaserde ...]
struct MyNamespace2 {
#[yaserde(flatten)]
fields: Fields
}
#[derive(YaDeserialize)]
struct Fields {
...
}
Like that you didn't re-wrote fields.
Thanks.
For example
I want to the
{namespace}
be alternative.Or, can I not specify
#[yaserde(namespace = "{namespace}")]
if the XML has a namespace?If I don't specify namespace, it will return
Error: bad namespace for xxx, found xxxx