public static XmlQueryType Type(XmlSchemaSimpleType schemaType, bool isStrict) {
if (schemaType.Datatype.Variety == XmlSchemaDatatypeVariety.Atomic) {
if (schemaType == DatatypeImplementation.AnySimpleType)
return AnyAtomicTypeS;
return ItemType.Create(schemaType, isStrict);
}
// Skip restrictions. It is safe to do that because this is a list or union, so it's not a build in type
while (schemaType.DerivedBy == XmlSchemaDerivationMethod.Restriction)
schemaType = (XmlSchemaSimpleType) schemaType.BaseXmlSchemaType;
// Convert Xsd list
if (schemaType.DerivedBy == XmlSchemaDerivationMethod.List)
return PrimeProduct(Type(((XmlSchemaSimpleTypeList) schemaType.Content).BaseItemType, isStrict), XmlQueryCardinality.ZeroOrMore);
// Convert Xsd union
Debug.Assert(schemaType.DerivedBy == XmlSchemaDerivationMethod.Union);
XmlSchemaSimpleType[] baseMemberTypes = ((XmlSchemaSimpleTypeUnion) schemaType.Content).BaseMemberTypes;
XmlQueryType[] queryMemberTypes = new XmlQueryType[baseMemberTypes.Length];
for (int i = 0; i < baseMemberTypes.Length; i++)
queryMemberTypes[i] = Type(baseMemberTypes[i], isStrict);
return Choice(queryMemberTypes);
}