1
在下面的模式中,行<xs:element type="cmn:AddressType" name="ResidentialAddress" minOccurs="1" maxOccurs="1" />
給出了錯誤Type 'http://company.com/Common:AddressType' is not declared
。爲什麼我可以從xsd模式導入此類型?
有誰知道爲什麼?它在Visual Studio 2008編輯器中顯示,並且如果我嘗試使用XDocument
驗證XML文件。
架構Student.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Student"
xmlns:cmn="http://company.com/Common"
targetNamespace="http://company.com/Student"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:import id="cmn" schemaLocation="Address.xsd"
namespace="http://company.com/Common" />
<xs:element name="Student" nillable="false">
<xs:complexType>
<xs:sequence minOccurs="1">
<xs:element name="Id" type="xs:integer" nillable="false" minOccurs="1" maxOccurs="1" />
<xs:element type="cmn:AddressType" name="ResidentialAddress" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
架構Address.xsd:
<xs:schema
targetNamespace="http://company.com/Common"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="AddressType">
<xs:complexType>
<xs:sequence>
<xs:element name="Line1" minOccurs="1" maxOccurs="1" />
<xs:element name="Line2" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
問題應該是「爲什麼我不能」而不是「爲什麼我」。 – 2010-03-11 15:16:25