使用xsd.exe生成的类

时间:2017-09-24 15:44:26

标签: c# xml xsd deserialization autosar

我使用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标记结构。我不知道为什么不反序列化。

有没有人知道这是因为根源?

0 个答案:

没有答案