Microsoft KB Archive/319372

= PRB: Limitations for DataSet Schema Files (XSD) =

Article ID: 319372

Article Last Modified on 10/29/2002

-

APPLIES TO


 * 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

-



This article was previously published under Q319372



SYMPTOMS
You may experience some limitations when you use a DataSet object to read a schema file that the DataSet object did not create.



Unique Constraints
The DataSet object only recognizes unique constraints if the unique element is located at the DataSet element level. For example, in the following schema file, you do not see the unique constraint, although this is a valid XML Schema Definition (XSD). 

























</xsd:element>

</xsd:sequence>

</xsd:complexType>

<xsd:unique name=&quot;unique1&quot;>

<xsd:selector xpath=&quot;./x1:parameter&quot; />

<xsd:field xpath=&quot;@name&quot; />

</xsd:unique>

</xsd:element>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema> The DataSet object does recognize the unique element in the following schema file:

<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?>

<xsd:schema id=&quot;configuration&quot; targetNamespace=&quot;http://microsoft.com/test/XMLSchema1.xsd&quot;

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

xmlns:msdata=&quot;urn:schemas-microsoft-com:xml-msdata&quot;

attributeFormDefault=&quot;qualified&quot; elementFormDefault=&quot;qualified&quot;>

<xsd:element name=&quot;configuration&quot; msdata:IsDataSet=&quot;true&quot; msdata:EnforceConstraints=&quot;true&quot;>



<xsd:sequence>

<xsd:element name=&quot;document&quot; minOccurs=&quot;1&quot; maxOccurs=&quot;unbounded&quot;>



<xsd:sequence>

<xsd:element name=&quot;parameter&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;>



<xsd:attribute name=&quot;name&quot; form=&quot;unqualified&quot; type=&quot;xsd:string&quot; use=&quot;required&quot; />

<xsd:attribute name=&quot;value&quot; form=&quot;unqualified&quot; type=&quot;xsd:string&quot; use=&quot;required&quot; />

</xsd:complexType>

</xsd:element>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:sequence>

</xsd:complexType>

<xsd:unique name=&quot;unique1&quot;>

<xsd:selector xpath=&quot;.//x1:parameter&quot; />

<xsd:field xpath=&quot;@name&quot; />

</xsd:unique>

</xsd:element>

</xsd:schema>

<div class="resolution_section">

RESOLUTION
Microsoft recommends that you use the WriteXmlSchema method of the DataSet object to create the schema files. This ensures that the DataSet object can use the schema file and is in a format that the DataSet object recognizes.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Use of Restriction Element Is Mostly Ignored
You can derive a new simple type by restricting an existing simple type with the restriction element. When you use the restriction element in simple types, the restriction element is ignored. Therefore, all the sub-elements of that restriction element are ignored also.

For example: <xsd:simpleType name=&quot;OrderID&quot;> <xsd:restriction base=&quot;xsd:string&quot;> <xsd:pattern value=&quot;\d{3}-[A-Z]{2}&quot;/> </xsd:restriction> </xsd:simpleType> All restriction elements are ignored except the XSD simple type &quot;string&quot;, and its facets as follows:
 * length
 * minlength
 * maxlength

<div class="references_section">