public static XmlQueryType Create(XmlTypeCode code, XmlQualifiedNameTest nameTest, XmlSchemaType contentType, bool isNillable) {
// If this is a Document, Element, or Attribute,
switch (code) {
case XmlTypeCode.Document:
case XmlTypeCode.Element:
if (nameTest.IsWildcard) {
// Normalize document(*, xs:anyType), element(*, xs:anyType)
if (contentType == XmlSchemaComplexType.AnyType)
return Create(code, false);
// Normalize document(xs:untypedAny), element(*, xs:untypedAny)
if (contentType == XmlSchemaComplexType.UntypedAnyType) {
Debug.Assert(!isNillable);
if (code == XmlTypeCode.Element)
return UntypedElement;
if (code == XmlTypeCode.Document)
return UntypedDocument;
}
}
// Create new ItemType
return new ItemType(code, nameTest, contentType, isNillable, false, true);
case XmlTypeCode.Attribute:
if (nameTest.IsWildcard) {
// Normalize attribute(xs:anySimpleType)
if (contentType == DatatypeImplementation.AnySimpleType)
return Create(code, false);
// Normalize attribute(xs:untypedAtomic)
if (contentType == DatatypeImplementation.UntypedAtomicType)
return UntypedAttribute;
}
// Create new ItemType
return new ItemType(code, nameTest, contentType, isNillable, false, true);
default:
return Create(code, false);
}
}