开发者

Does xsd.exe identify numerical fields?

When I use xsd.exe to generate C# classes for a given XML with minimal metadata, does it recognize numerical attributtes (and InnerTextes) and map 开发者_StackOverflow社区them to properties of numerical types (ie: int, double)?


A quick test:

<test>
    <i>123</i>
    <f>12.3</f>
    <s>abc</s>
</test>

then:

xsd test.xml
xsd test.xsd /c

gives:

  <xs:element name="test">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="i" type="xs:string" minOccurs="0" />
        <xs:element name="f" type="xs:string" minOccurs="0" />
        <xs:element name="s" type="xs:string" minOccurs="0" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

and:

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string i {
    get {
        return this.iField;
    }
    set {
        this.iField = value;
    }
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string f {
    get {
        return this.fField;
    }
    set {
        this.fField = value;
    }
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string s {
    get {
        return this.sField;
    }
    set {
        this.sField = value;
    }
}

So I'm going to vote "not very reliably, if at all".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜