我用XSD生成器得到了一個奇怪的行爲,我無法真正解釋。我有一個這樣的XSD:當生成C#代碼時,XSD工具將「指定」附加到某些屬性/字段
<xs:complexType name="StageSequenceElement" mixed="false">
<xs:complexContent>
<xs:extension base="CoreObject">
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Some Doc</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="StageRef" type="ObjectReference">
<xs:annotation>
<xs:documentation>...</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MinDuration_100ms" type="xs:int" nillable="true" minOccurs="0">
<xs:annotation>
<xs:documentation>...</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MaxDuration_100ms" type="xs:int" nillable="true">
<xs:annotation>
<xs:documentation>...</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="StageOnDemand" type="xs:boolean" nillable="true" minOccurs="0">
<xs:annotation>
<xs:documentation>...</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
它是從CoreObject得出:
<xs:complexType name="CoreObject">
<xs:sequence>
<xs:element name="No" type="xs:int">
<xs:annotation>
<xs:documentation>...</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
這是XSD的只是一小部分,還有很多更復雜的類型。
所以,當我生成類似於this類,我得到一個生成的類,它有兩個屬性(除5這是我所期望的):
public bool MinDuration_100msSpecified
和
public bool StageOnDemandSpecified
所以到「原始」屬性「指定」被追加和類型現在布爾。 任何人都可以解釋爲什麼這樣嗎?
謝謝,有沒有辦法阻止創建該屬性? – derape
您可以嘗試提供更多功能的xsd2code工具。 http://xsd2code.codeplex.com/ –
那麼我們最終得到了一個由我們自己的代碼生成器,它符合我們的需求,但是無論如何感謝:-) – derape