1
我想在XSD文件上運行Xsd.exe,並且出現以下錯誤。我正在使用IMPORT,因爲主機名稱空間與外部名稱空間不同。Xsd.exe導入ComplexType時無法生成類
A2.xsd取決於A21.xsd,而這又取決於A22.xsd(全部都在同一個文件夾)
ERROR: "The datatype 'http://service.a1.com/base1/2005/:EmployeeDefinition' is missing"
xsd.exe /classes /out:C:\Temp\ "C:\Temp\A2.xsd" /language:CS
A2.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.a1.com/base/2005/" xmlns:c1="http://service.a1.com/base1/2005/" elementFormDefault="qualified">
<xs:import namespace="http://service.a1.com/base1/2005/" schemaLocation="a21.xsd"/>
<xs:element name="Employee" nillable="true" type="c1:EmployeeDefinition" />
</xs:schema>
A21,XSD
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.a1.com/base1/2005/" xmlns:n2="http://service.a1.com/base2/2005/" elementFormDefault="qualified">
<xs:import namespace="http://service.a1.com/base2/2005/" schemaLocation="a22.xsd"/>
<xs:complexType name="EmployeeDefinition">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="EmployeeID" type="xs:int" />
<xs:element minOccurs="0" maxOccurs="1" name="FirstName" type="xs:string" />
<xs:element name="Address" nillable="true" type="n2:AddressDefinition" />
</xs:sequence>
</xs:complexType>
</xs:schema>
A22.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.a1.com/base2/2005/" elementFormDefault="qualified">
<xs:complexType name="AddressDefinition">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="HouseNumber" type="xs:int" />
<xs:element minOccurs="0" maxOccurs="1" name="StreetName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
請讓我知道這裏發生了什麼。
非常感謝你。這解決了我的問題 – user1174790