我使用 AUTOSAR 联盟提供的 XSD 文件中的 xsd.exe 生成了类。
我想反序列化以下 XML 代码:
<END-TO-END-PROTECTION-VARIABLE-PROTOTYPES>
<END-TO-END-PROTECTION-VARIABLE-PROTOTYPE T="2017-07-31T13:37:48Z">
<RECEIVER-IREFS>
<RECEIVER-IREF>
<VARIABLE-DATA-PROTOTYPE-IN-SYSTEM-INSTANCE-REF T="2017-07-31T13:37:48Z">
<CONTEXT-COMPOSITION-REF DEST="ROOT-SW-COMPOSITION-PROTOTYPE">/Some/Reference/Value</CONTEXT-COMPOSITION-REF>
<TARGET-DATA-PROTOTYPE-REF DEST="VARIABLE-DATA-PROTOTYPE">/Another/Reference/Value</TARGET-DATA-PROTOTYPE-REF>
</VARIABLE-DATA-PROTOTYPE-IN-SYSTEM-INSTANCE-REF>
</RECEIVER-IREF>
</RECEIVER-IREFS>
</END-TO-END-PROTECTION-VARIABLE-PROTOTYPE>
</END-TO-END-PROTECTION-VARIABLE-PROTOTYPES>
但遗憾的是<RECEIVER-IREF>
内容没有连载。
为访问生成的类如下:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(TypeName="END-TO-END-PROTECTION-VARIABLE-PROTOTYPE", Namespace="http://autosar.org/schema/r4.0")]
public partial class ENDTOENDPROTECTIONVARIABLEPROTOTYPE {
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute("RECEIVER-IREFS", Order=0)]
[System.Xml.Serialization.XmlArrayItemAttribute("RECEIVER-IREF", IsNullable=false)]
public VARIABLEDATAPROTOTYPEINSYSTEMINSTANCEREF[] RECEIVERIREFS;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string S;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("SENDER-IREF", Order=1)]
public VARIABLEDATAPROTOTYPEINSYSTEMINSTANCEREF SENDERIREF;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("SHORT-LABEL", Order=2)]
public IDENTIFIER SHORTLABEL;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string T;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("VARIATION-POINT", Order=3)]
public VARIATIONPOINT VARIATIONPOINT;
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(TypeName="VARIABLE-DATA-PROTOTYPE-IN-SYSTEM-INSTANCE-REF", Namespace="http://autosar.org/schema/r4.0")]
public partial class VARIABLEDATAPROTOTYPEINSYSTEMINSTANCEREF {
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("CONTEXT-COMPONENT-REF", Order=0)]
public VARIABLEDATAPROTOTYPEINSYSTEMINSTANCEREFCONTEXTCOMPONENTREF[] CONTEXTCOMPONENTREF;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("CONTEXT-COMPOSITION-REF", Order=1)]
public VARIABLEDATAPROTOTYPEINSYSTEMINSTANCEREFCONTEXTCOMPOSITIONREF CONTEXTCOMPOSITIONREF;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("CONTEXT-PORT-REF", Order=2)]
public VARIABLEDATAPROTOTYPEINSYSTEMINSTANCEREFCONTEXTPORTREF CONTEXTPORTREF;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string S;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string T;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("TARGET-DATA-PROTOTYPE-REF", Order=3)]
public VARIABLEDATAPROTOTYPEINSYSTEMINSTANCEREFTARGETDATAPROTOTYPEREF TARGETDATAPROTOTYPEREF;
}
生成的类似乎是正确的,XML 标记结构也是如此。我不知道为什么不反序列化。
有人知道这件事的根本原因吗?