Element serializeSimpleTypeUnion()

in src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java [2129:2164]


    Element serializeSimpleTypeUnion(Document doc, XmlSchemaSimpleTypeUnion unionObj, XmlSchema schema)
        throws XmlSchemaSerializerException {

        Element union = createNewElement(doc, "union", schema.getSchemaNamespacePrefix(),
                                         XmlSchema.SCHEMA_NS);
        if (unionObj.getId() != null) {
            union.setAttribute("id", unionObj.getId());
        }

        if (unionObj.getMemberTypesSource() != null) {
            union.setAttribute("memberTypes", unionObj.getMemberTypesSource());
        }
        if (unionObj.getBaseTypes().size() > 0) {
            int baseTypesLength = unionObj.getBaseTypes().size();
            Element baseType;
            for (int i = 0; i < baseTypesLength; i++) {
                try {
                    baseType = serializeSimpleType(doc, (XmlSchemaSimpleType)unionObj.getBaseTypes().get(i),
                                                   schema);
                    union.appendChild(baseType);
                } catch (ClassCastException e) {
                    throw new XmlSchemaSerializerException("only inline simple type allow as attribute's "
                                                           + "inline type");
                }
            }
        }
        if (unionObj.getAnnotation() != null) {
            Element annotation = serializeAnnotation(doc, unionObj.getAnnotation(), schema);
            union.appendChild(annotation);
        }

        // process extension
        processExtensibilityComponents(unionObj, union);

        return union;
    }