2012-11-08 99 views
3

我有多個描述對象的XSD文件。我想從這些對象中生成類,以便我可以解析一個XML並創建該對象。我用xsd.exe該Visual Studio提供如下:xsd.exe類生成器問題與多個xsd文件

XSD/C efreight-CommonReportingSchema-1.0.xsd ../common/efreight-CommonReportingSchemaExtensions-1.0.xsd ../common/UBL-CommonAggregateComponents-2.1的.xsd ../common/UBL-CommonBasicComponents-2.1.xsd ../common/UBL-UnqualifiedDataTypes-2.1.xsd

efreight-CommonReportingSchema-1.0.xsd文件:

<!-- ===== Imports ===== --> 
<xsd:import namespace="urn:eu:specification:efreight:schema:xsd:CommonReportingSchemaExtensions-1.0" schemaLocation="../common/efreight-CommonReportingSchemaExtensions-1.0.xsd"/> 
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" schemaLocation="../common/UBL-CommonAggregateComponents-2.1.xsd"/> 
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" schemaLocation="../common/UBL-CommonBasicComponents-2.1.xsd"/> 
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2" schemaLocation="../common/UBL-UnqualifiedDataTypes-2.1.xsd"/> 

<!-- ===== Common Reporting Schema Definition ===== --> 
<xsd:element name="CommonReportingSchema" type="CommonReportingSchemaType"> 
</xsd:element> 

<xsd:complexType name="CommonReportingSchemaType"> 
    <xsd:sequence>   
     <xsd:element ref="cbc:UBLVersionID" minOccurs="0" maxOccurs="1"/> 
     <xsd:element ref="cbc:CustomizationID" minOccurs="1" maxOccurs="1"/> 
     <xsd:element ref="cbc:ProfileID" minOccurs="0" maxOccurs="1"/> 
     <xsd:element ref="cbc:ID" minOccurs="1" maxOccurs="1"/> 
     <xsd:element ref="cbc:VersionID" minOccurs="0" maxOccurs="1"/> 
     <xsd:element ref="cbc:TransportExecutionPlanReferenceID" minOccurs="0" maxOccurs="1"/> 
     <xsd:element ref="crs:SubmissionDate" minOccurs="0" maxOccurs="1"/> 
     <xsd:element ref="crs:SubmissionTime" minOccurs="0" maxOccurs="1"/> 
     <xsd:element ref="crs:ReportingParty" minOccurs="1" maxOccurs="1"/> 
     <xsd:element ref="crs:Consignment" minOccurs="0" maxOccurs="unbounded"/> 
     <xsd:element ref="crs:TransportMeans" minOccurs="0" maxOccurs="1"/>   
     <xsd:element ref="cac:DocumentReference" minOccurs="0" maxOccurs="unbounded"/> 
    </xsd:sequence> 
</xsd:complexType> 

的CS文件被成功生成,但是當我嘗試分析對象,會出現類似下面幾個錯誤:

錯誤CS0266:無法隱式轉換類型「ShipmentStageType [ ]'至 'ShipmentStageType1 []'。一個顯式轉換存在(是否缺少 強制轉換?)

錯誤CS0266:無法隱式轉換類型 'TransportHandlingUnitType []' 到 'TransportHandlingUnitType1 []'。一個 顯式轉換存在(是否缺少強制轉換?)

錯誤CS0266:無法隱式轉換類型 'ConsignmentType []' 到 'ConsignmentType1 []'。一個顯式轉換存在(是否缺少 投?)

我從錯誤中看到的是,出事了班上的產生。我認爲有幾個類被聲明瞭兩次,這就是爲什麼'1'被放在名稱末尾的原因。

是否有某種配置更改可用於xsd.exe?或者是由其他地方引起的錯誤?

謝謝。

回答

0

我寫了一個小腳本,循環的文件和打印他們的文件名,所以我可以使用:

XSD.EXE/C file1.xsd file2.xsd file3.xsd

這應該工作:)

PS。我知道我參加派對遲到了;)