文章編號: 319372 - 上次校閱: 2002年10月29日 - 版次: 1.2

資料集結構描述檔案 (XSD) 的 PRB: 限制

系統提示本文適用於您使用的作業系統之外的作業系統。與您不相關的文章內容已停用。

在此頁中

全部展開 | 全部摺疊

徵狀

當您使用 資料集 物件來讀取 資料集 物件不是自己建立的結構描述檔案時,可能會遇到一些限制。

發生的原因

唯一的條件約束

如果在 資料集 項目層級唯一的項目位於 DataSet 物件只會辨識唯一的條件約束。例如在下列的結構描述檔中看不到唯一的條件約束雖然這是有效的 「 XML 結構描述定義 (XSD)。
<?xml version="1.0" encoding="utf-8" ?> 

 

  <xsd:schema id="configuration"  targetNamespace="http://microsoft.com/test/XMLSchema1.xsd" 

     xmlns:x1="http://microsoft.com/test/XMLSchema1.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 

     xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 

     attributeFormDefault="qualified" elementFormDefault="qualified">

     <xsd:element name="configuration" msdata:IsDataSet="true" msdata:EnforceConstraints="true">

         <xsd:complexType>

                <xsd:sequence>

                     <xsd:element name="document" minOccurs="1" maxOccurs="unbounded">

                           <xsd:complexType>

                                <xsd:sequence>

                                   <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">

                                       <xsd:complexType>

                                         <xsd:attribute name="name" form="unqualified" type="xsd:string" use="required" />

                                         <xsd:attribute name="value" form="unqualified" type="xsd:string" use="required" />

                                       </xsd:complexType>

                                    </xsd:element>

                                </xsd:sequence>

                             </xsd:complexType>

                             <xsd:unique name="unique1">

                                <xsd:selector xpath="./x1:parameter" />

                                <xsd:field xpath="@name" />

                             </xsd:unique>

                     </xsd:element>

                </xsd:sequence>

            </xsd:complexType>

        </xsd:element>

  </xsd:schema>
				
DataSet 物件不會辨識下列的結構描述檔中唯一的項目:
<?xml version="1.0" encoding="utf-8" ?> 

 

  <xsd:schema id="configuration"  targetNamespace="http://microsoft.com/test/XMLSchema1.xsd" 

     xmlns:x1="http://microsoft.com/test/XMLSchema1.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 

     xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 

     attributeFormDefault="qualified" elementFormDefault="qualified">

     <xsd:element name="configuration" msdata:IsDataSet="true" msdata:EnforceConstraints="true">

         <xsd:complexType>

                <xsd:sequence>

                     <xsd:element name="document" minOccurs="1" maxOccurs="unbounded">

                           <xsd:complexType>

                                <xsd:sequence>

                                   <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">

                                       <xsd:complexType>

                                         <xsd:attribute name="name" form="unqualified" type="xsd:string" use="required" />

                                         <xsd:attribute name="value" form="unqualified" type="xsd:string" use="required" />

                                       </xsd:complexType>

                                    </xsd:element>

                                </xsd:sequence>

                             </xsd:complexType>

                       </xsd:element>

                </xsd:sequence>

            </xsd:complexType>

<xsd:unique name="unique1">

                  <xsd:selector xpath=".//x1:parameter" />

                  <xsd:field xpath="@name" />

             </xsd:unique>

        </xsd:element>

  </xsd:schema>


				

解決方案

Microsoft 建議您使用的 DataSet 物件 WriteXmlSchema 方法來建立結構描述檔案。這樣可以確保 DataSet 物件可以使用結構描述檔案,並為 DataSet 物件可辨識的格式。

狀況說明

這種行為是經過設計規劃的。

其他相關資訊

限制項目使用大多是會被略過

您可以藉由限制與 限制 項目一個現有簡單型別衍生新的簡單型別。當您在簡單的型別中使用 限制 項目時,限制 項目會被忽略。因此,會也忽略該 限制 項目的所有子項目。
例如:
<xsd:simpleType name="OrderID">
  <xsd:restriction base="xsd:string">
   <xsd:pattern value="\d{3}-[A-Z]{2}"/>
  </xsd:restriction>
 </xsd:simpleType>
				
全部 限制 會忽略項目 XSD 簡單的型別"string"和其 Facet 除外,如下所示:
  • 長度
  • minlength
  • maxlength

?考

如需有關資料集和 XSD 的詳細資訊,請參閱 「 書寫資料集結構描述資訊做為 XML 結構描述 (XSD) 」 主題在下列 Microsoft 開發 o 人 h 員 ? 工 u 具 ? 網路 (MSDN):
Writing DataSet Schema Information as XML Schema (XSD) (http://msdn.microsoft.com/en-us/library/aa735743.aspx)
注意: 這個資訊則也可以使用 Microsoft Visual Studio.NET 說明的文件中。

這篇文章中的資訊適用於:
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
關鍵字:?
kbmt kbprb KB319372 KbMtzh
機器翻譯機器翻譯
重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。
按一下這裡查看此文章的英文版本:319372? (http://support.microsoft.com/kb/319372/en-us/ )
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。