public static XmlQueryType Choice(params XmlQueryType[] types) {
if (types.Length == 0)
return None;
else if (types.Length == 1)
return types[0];
// Union each type with next type
List<XmlQueryType> list = new List<XmlQueryType>(types[0]);
XmlQueryCardinality card = types[0].Cardinality;
for (int i = 1; i < types.Length; i++) {
PrimeChoice(list, types[i]);
card |= types[i].Cardinality;
}
return SequenceType.Create(ChoiceType.Create(list), card);
}