Closed victor-soloviev closed 4 years ago
The problem with these names is easy to solve. But there is a problem with namespaces: they can be imported under aliases.
<xs:restriction base="xs:QName">
<xs:enumeration value="tns:DataEncodingUnknown"/>
<xs:enumeration value="tns:MustUnderstand"/>
<xs:enumeration value="tns:Receiver"/>
<xs:enumeration value="tns:Sender"/>
<xs:enumeration value="tns:VersionMismatch"/>
</xs:restriction>
godgen output:
#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)]
pub enum FaultcodeEnum {
#[yaserde(rename = "tns:DataEncodingUnknown")]
DataEncodingUnknown,
#[yaserde(rename = "tns:MustUnderstand")]
MustUnderstand,
#[yaserde(rename = "tns:Receiver")]
Receiver,
#[yaserde(rename = "tns:Sender")]
Sender,
#[yaserde(rename = "tns:VersionMismatch")]
VersionMismatch,
__Unknown__(String),
}
but 'tns' namespace could import as 's', for example:
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value>ter:NotAuthorized</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en">Sender not Authorized</s:Text>
</s:Reason>
</s:Fault>
We can't just compare lines, we can't just set a line in "rename" and we can't validate it like
available_values.contains(¤t_value)
Enumerations may have values with punctuation within it. Currently, the following XSD
translates to
We should eather escape punctuation characters or store enumeration as strings with a value validation.