internal void HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, bool isNillable)
{
if (_complexTypes.Contains(ct))
throw ExceptionBuilder.CircularComplexType(ct.Name);
bool isBase = false;
_complexTypes.Add(ct);
if (ct.ContentModel != null)
{
/*
HandleParticle(ct.CompiledParticle, table, tableChildren, isBase);
foreach (XmlSchemaAttribute s in ct.Attributes){
HandleAttributeColumn(s, table, isBase);
}
*/
if (ct.ContentModel is XmlSchemaComplexContent)
{
XmlSchemaAnnotated cContent = ((XmlSchemaComplexContent)(ct.ContentModel)).Content;
if (cContent is XmlSchemaComplexContentExtension)
{
XmlSchemaComplexContentExtension ccExtension = ((XmlSchemaComplexContentExtension)cContent);
if (!(ct.BaseXmlSchemaType is XmlSchemaComplexType && FromInference))
HandleAttributes(ccExtension.Attributes, table, isBase);
if (ct.BaseXmlSchemaType is XmlSchemaComplexType)
{
HandleComplexType((XmlSchemaComplexType)ct.BaseXmlSchemaType, table, tableChildren, isNillable);
}
else
{
Debug.Assert(ct.BaseXmlSchemaType is XmlSchemaSimpleType, "Expected SimpleType or ComplexType");
if (ccExtension.BaseTypeName.Namespace != Keywords.XSDNS)
{
// this is UDSimpleType, pass Qualified name of type
HandleSimpleContentColumn(ccExtension.BaseTypeName.ToString(), table, isBase, ct.ContentModel.UnhandledAttributes, isNillable);
}
else
{ // it is built in type
HandleSimpleContentColumn(ccExtension.BaseTypeName.Name, table, isBase, ct.ContentModel.UnhandledAttributes, isNillable);
}
}
if (ccExtension.Particle != null)
HandleParticle(ccExtension.Particle, table, tableChildren, isBase);
if (ct.BaseXmlSchemaType is XmlSchemaComplexType && FromInference)
HandleAttributes(ccExtension.Attributes, table, isBase);
}
else
{
Debug.Assert(cContent is XmlSchemaComplexContentRestriction, "Expected complexContent extension or restriction");
XmlSchemaComplexContentRestriction ccRestriction = ((XmlSchemaComplexContentRestriction)cContent);
if (!FromInference)
HandleAttributes(ccRestriction.Attributes, table, isBase);
if (ccRestriction.Particle != null)
HandleParticle(ccRestriction.Particle, table, tableChildren, isBase);
if (FromInference)
HandleAttributes(ccRestriction.Attributes, table, isBase);
}
}
else
{
Debug.Assert(ct.ContentModel is XmlSchemaSimpleContent, "expected simpleContent or complexContent");
XmlSchemaAnnotated cContent = ((XmlSchemaSimpleContent)(ct.ContentModel)).Content;
if (cContent is XmlSchemaSimpleContentExtension)
{
XmlSchemaSimpleContentExtension ccExtension = ((XmlSchemaSimpleContentExtension)cContent);
HandleAttributes(ccExtension.Attributes, table, isBase);
if (ct.BaseXmlSchemaType is XmlSchemaComplexType)
{
HandleComplexType((XmlSchemaComplexType)ct.BaseXmlSchemaType, table, tableChildren, isNillable);
}
else
{
Debug.Assert(ct.BaseXmlSchemaType is XmlSchemaSimpleType, "Expected SimpleType or ComplexType");
HandleSimpleTypeSimpleContentColumn((XmlSchemaSimpleType)ct.BaseXmlSchemaType, ccExtension.BaseTypeName.Name, table, isBase, ct.ContentModel.UnhandledAttributes, isNillable);
}
}
else
{
Debug.Assert(cContent is XmlSchemaSimpleContentRestriction, "Expected SimpleContent extension or restriction");
XmlSchemaSimpleContentRestriction ccRestriction = ((XmlSchemaSimpleContentRestriction)cContent);
HandleAttributes(ccRestriction.Attributes, table, isBase);
}
}
}
else
{
isBase = true;
if (!FromInference)
HandleAttributes(ct.Attributes, table, isBase);
if (ct.Particle != null)
HandleParticle(ct.Particle, table, tableChildren, isBase);
if (FromInference)
{
HandleAttributes(ct.Attributes, table, isBase);
if (isNillable) // this is for backward compatability to support xsi:Nill=true
HandleSimpleContentColumn("string", table, isBase, null, isNillable);
}
}
_complexTypes.Remove(ct);
}