为什么xdx.exe为xs生成字符串属性:nonNegativeInteger?

时间:2016-10-28 15:19:42

标签: .net visual-studio-2015 xsd.exe

我的元素:

<xs:element name="achats" type="xs:nonNegativeInteger" minOccurs="0"/>

生成为:

[System.Xml.Serialization.XmlElementAttribute(DataType="nonNegativeInteger")]
public string achats
{
   ...
}

为什么不将此属性生成为十进制而不是字符串? 在本文档中,它应该是System.Decimal https://msdn.microsoft.com/fr-fr/library/aa719879(v=vs.71).aspx

XSD是由其他公司发送的,所以我无法真正修改它。我想我没有正确使用xsd.exe但我不知道如何......

提前致谢

1 个答案:

答案 0 :(得分:0)

似乎在较新版本的.net中是正常的:

  

nonNegativeInteger |串

https://msdn.microsoft.com/fr-fr/library/system.xml.serialization.xmlelementattribute.datatype(v=vs.110).aspx

而W3写道

  

[定义:] nonNegativeInteger是通过将·minInclusive·的值设置为0来从整数派生的

https://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#nonNegativeInteger