我从OTA(开放式旅游联盟)XSD文件生成C#类。你可以download the XSD file from here。为什么有些生成的C#类属性不匹配XSD属性?
我在Visual Studio命令提示符创建具有以下命令的C#类:
xsd FS_OTA_VehLocDetailsNotifRQ.xsd /classes /nologo
在OTA_VehLocDetailsNotifRQ.POS[0].RequestorID
我希望找到一个ID
财产。然而,由XSD.exe工具生成的属性名为ID_Context
。
你能否解释一下为什么这样做,以及是否我能够迫使它产生正确的(ID
)属性名?
请不要建议我编辑生成的文件,因为这是不是一个维护的方法。
接受答案后进一步编辑:
望着XSD更紧密地和更换他们的属性组定义的引用,ID属性可以看到它的属性组:
<xs:attributeGroup name="UniqueID_Group">
<xs:attribute name="URL" type="xs:anyURI" />
<xs:attribute name="Type" type="OTA_CodeType" use="required" />
<xs:attribute name="Instance" type="StringLength1to32" />
<xs:attributeGroup name="ID_Group">
<xs:attribute name="ID" type="StringLength1to32" use="required" />
</xs:attributeGroup>
<xs:attribute name="ID_Context" type="StringLength1to32" use="optional" />
</xs:attributeGroup>
我相信这是XSD工具中的一个错误。
哇,我错过了这一步;做得很好,正如你所说,ID_Group的跳过是问题,这太可惜了,它的属性是 – 2009-11-25 16:51:22