private void readXmlSchemaElement(XmlSchemaElement element, XmlSchemaElement parent)
{
//Debug.WriteLine("----------------------------------------------");
string name = "";
for (int i = 0; i < area; i++)
{
name += "-";
}
name += element.Name;
Debug.WriteLine(name);
// Get the complex type of the Customer element.
XmlSchemaComplexType complexType = element.ElementSchemaType as XmlSchemaComplexType;
if (complexType != null)
{
packages++;
//Debug.WriteLine(" Type : " + complexType.GetType().FullName);
// If the complex type has any attributes, get an enumerator
// and write each attribute name to the Debug.
if (complexType.AttributeUses.Count > 0)
{
IDictionaryEnumerator enumerator =
complexType.AttributeUses.GetEnumerator();
while (enumerator.MoveNext())
{
XmlSchemaAttribute attribute =
(XmlSchemaAttribute)enumerator.Value;
//Debug.WriteLine("Attribute: " + attribute.Name);
}
}
if (complexType.ContentModel != null)
{
//Debug.WriteLine(" ContentModel Type : " + complexType.ContentModel.GetType().FullName);
if (complexType.ContentModel.GetType().Equals(typeof(XmlSchemaSimpleContent)))
{
metadataAttributeNames.Add(element.Name);
int count = GetXmlSchemaElementCount(parent);
//if (count == 1)
//{
// string parentName = findParentElement(parent.Parent).Name;
// if (!metadataPackageNames.Contains(parentName)) metadataPackageNames.Add(parentName);
//}
//else
if (!metadataPackageNames.Contains(parent.Name)) metadataPackageNames.Add(parent.Name);
//ChildIsLast = true;
}
}
//Debug.WriteLine(" ContentModel Type : null");
// Get the sequence particle of the complex type.
XmlSchemaSequence sequence = complexType.ContentTypeParticle as XmlSchemaSequence;
if (sequence != null)
{
area++;
// Iterate over each XmlSchemaElement in the Items collection.
foreach (XmlSchemaObject childElement in sequence.Items)
{
//Debug.WriteLine(" ChildElement: "+ childElement.Name);
if (childElement.GetType().Equals(typeof(XmlSchemaElement)))
readXmlSchemaElement((XmlSchemaElement)childElement, element);
else if (childElement.GetType().Equals(typeof(XmlSchemaAny)))
{
XmlSchemaAny xsy = (XmlSchemaAny)childElement;
Debug.WriteLine("+++++++++++++++++++++++++SPECIAL XMLSCHEMAANY : " + xsy.ToString());
}
else
Debug.WriteLine("**************************XMLSCHEMAOBJECT: " + childElement.LineNumber + " : "+ childElement.LinePosition);
}
if(ChildIsLast)
{
metadataPackageNames.Add(element.Name);
ChildIsLast = false;
}
area--;
}
}
//Debug.WriteLine("----------------------------------------------");
}