Element serializeRedefine()

in src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java [1488:1537]


    Element serializeRedefine(Document doc, XmlSchemaRedefine redefineObj, XmlSchema schema)
        throws XmlSchemaSerializerException {

        Element redefine = createNewElement(doc, "redefine", schema.getSchemaNamespacePrefix(),
                                            XmlSchema.SCHEMA_NS);

        if (redefineObj.schemaLocation != null) {
            redefine.setAttribute("schemaLocation", redefineObj.schemaLocation);
        } else {
            throw new XmlSchemaSerializerException("redefine must have " + "schemaLocation fields fill");
        }

        if (redefineObj.getId() != null) {
            redefine.setAttribute("id", redefineObj.getId());
        }

        if (redefineObj.getAnnotation() != null) {
            Element annotation = serializeAnnotation(doc, redefineObj.getAnnotation(), schema);
            redefine.appendChild(annotation);
        }
        int itemsLength = redefineObj.getItems().size();
        for (int i = 0; i < itemsLength; i++) {
            XmlSchemaObject obj = redefineObj.getItems().get(i);
            if (obj instanceof XmlSchemaSimpleType) {
                Element simpleType = serializeSimpleType(doc, (XmlSchemaSimpleType)obj, schema);
                redefine.appendChild(simpleType);
            } else if (obj instanceof XmlSchemaComplexType) {
                Element complexType = serializeComplexType(doc, (XmlSchemaComplexType)obj, schema);
                redefine.appendChild(complexType);
            } else if (obj instanceof XmlSchemaGroupRef) {
                Element groupRef = serializeGroupRef(doc, (XmlSchemaGroupRef)obj, schema);
                redefine.appendChild(groupRef);
            } else if (obj instanceof XmlSchemaGroup) {
                Element group = serializeGroup(doc, (XmlSchemaGroup)obj, schema);
                redefine.appendChild(group);
            } else if (obj instanceof XmlSchemaAttributeGroup) {
                Element attributeGroup = serializeAttributeGroup(doc, (XmlSchemaAttributeGroup)obj, schema);
                redefine.appendChild(attributeGroup);
            } else if (obj instanceof XmlSchemaAttributeGroupRef) {
                Element attributeGroupRef = serializeAttributeGroupRef(doc, (XmlSchemaAttributeGroupRef)obj,
                                                                       schema);
                redefine.appendChild(attributeGroupRef);
            }
        }

        // process extension
        processExtensibilityComponents(redefineObj, redefine);

        return redefine;
    }