public void WriteXmlSchema6()
{
string xmlschema = @"<?xml version=""1.0"" encoding=""utf-16""?>
<xs:schema id=""Example"" xmlns="""" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"">
" +
@" <xs:element name=""Example"" msdata:IsDataSet=""true"" msdata:UseCurrentLocale=""true"""
+ @">
<xs:complexType>
<xs:choice minOccurs=""0"" maxOccurs=""unbounded"">
<xs:element name=""MyType"">
<xs:complexType>
<xs:attribute name=""Desc"">
<xs:simpleType>
<xs:restriction base=""xs:string"">
<xs:maxLength value=""32"" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>";
DataSet ds = new DataSet("Example");
// Add MyType DataTable
ds.Tables.Add("MyType");
ds.Tables["MyType"].Columns.Add(new DataColumn(
"Desc", typeof(string), "", MappingType.Attribute));
ds.Tables["MyType"].Columns["Desc"].MaxLength = 32;
ds.AcceptChanges();
StringWriter sw = new StringWriter();
ds.WriteXmlSchema(sw);
string result = sw.ToString();
Assert.Equal(result.Replace("\r\n", "\n"), xmlschema.Replace("\r\n", "\n"));
}