use of eu.esdihumboldt.hale.io.xsd.reader.internal.constraint.UnionEnumeration in project hale by halestudio.
the class XmlTypeUtil method configureSimpleTypeUnion.
/**
* Configure a type definition for a simple type based on a simple type
* union.
*
* @param type the type definition
* @param union the simple type union
* @param index the XML index for resolving type definitions
* @param reporter the report
*/
private static void configureSimpleTypeUnion(XmlTypeDefinition type, XmlSchemaSimpleTypeUnion union, XmlIndex index, IOReporter reporter) {
XmlSchemaObjectCollection baseTypes = union.getBaseTypes();
// collect type definitions
Set<TypeDefinition> unionTypes = new HashSet<TypeDefinition>();
if (union.getMemberTypesQNames() != null) {
for (QName unionMember : union.getMemberTypesQNames()) unionTypes.add(index.getOrCreateType(unionMember));
}
// base type definitions
if (baseTypes != null && baseTypes.getCount() > 0) {
for (int i = 0; i < baseTypes.getCount(); i++) {
XmlSchemaObject baseType = baseTypes.getItem(i);
if (baseType instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) baseType;
// Here it is a xs:localSimpleTypes, name attribute is
// prohibited!
// So it always is a anonymous type.
QName baseName = new QName(type.getName().getNamespaceURI() + "/" + type.getName().getLocalPart(), // $NON-NLS-1$ //$NON-NLS-2$
"AnonymousType" + i);
XmlTypeDefinition baseDef = new AnonymousXmlType(baseName);
configureSimpleType(baseDef, simpleType, index, reporter);
unionTypes.add(baseDef);
} else {
reporter.error(new IOMessageImpl("Unrecognized base type for simple type union", null, union.getLineNumber(), union.getLinePosition()));
}
}
}
// binding constraint
type.setConstraint(new UnionBinding(unionTypes));
// enumeration constraint
type.setConstraint(new UnionEnumeration(unionTypes));
// validation constraint
type.setConstraint(new UnionValidationConstraint(unionTypes));
}
Aggregations