private void WriteTableType(DataTable table) { ArrayList elements; ArrayList atts; DataColumn simple; DataSet.SplitColumns(table, out atts, out elements, out simple); w.WriteStartElement("xs", "complexType", xmlnsxs); if (simple != null) { w.WriteStartElement("xs", "simpleContent", xmlnsxs); // add column name attribute w.WriteAttributeString( XmlConstants.MsdataPrefix, XmlConstants.ColumnName, XmlConstants.MsdataNamespace, XmlHelper.Encode(simple.ColumnName)); // add ordinal attribute w.WriteAttributeString( XmlConstants.MsdataPrefix, XmlConstants.Ordinal, XmlConstants.MsdataNamespace, XmlConvert.ToString(simple.Ordinal)); // add extension w.WriteStartElement("xs", "extension", xmlnsxs); w.WriteStartAttribute("base", String.Empty); WriteQName(MapType(simple.DataType)); w.WriteEndAttribute(); WriteTableAttributes(atts); w.WriteEndElement(); } else { WriteTableAttributes(atts); bool isNested = false; foreach (DataRelation rel in table.ParentRelations) { if (rel.Nested) { isNested = true; break; } } // When we have a nested relationship and only one table, // could be that we have a reference attribute if (elements.Count > 0 || (isNested && tables.Length < 2)) { w.WriteStartElement("xs", "sequence", xmlnsxs); foreach (DataColumn col in elements) { WriteTableTypeParticles(col); } foreach (DataRelation rel in table.ChildRelations) { if (rel.Nested) { WriteChildRelations(rel); } } w.WriteEndElement(); } } w.WriteFullEndElement(); // complexType }