PRB: Limitations for DataSet Schema Files (XSD) (319372)
The information in this article applies to:
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- 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.
CAUSEUnique 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).
<?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>
The DataSet object does recognize the unique element in the following schema file:
<?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>
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.
STATUSThis behavior is by design.REFERENCES
For more information about the DataSets and XSD, see the "Writing DataSet Schema Information as XML Schema (XSD)" topic at the following Microsoft Developer Network (MSDN):
NOTE: This information is also available in the Microsoft Visual Studio .NET Help documentation.
Modification Type: | Major | Last Reviewed: | 10/29/2002 |
---|
Keywords: | kbprb KB319372 kbAudDeveloper |
---|
|