Element serializeComplexType()

in src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java [865:951]


    Element serializeComplexType(Document doc, XmlSchemaComplexType complexTypeObj, XmlSchema schema)
        throws XmlSchemaSerializerException {

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

        if (!complexTypeObj.isAnonymous()) {
            serializedComplexType.setAttribute("name", complexTypeObj.getName());
            /*
             * if(complexTypeObj.annotation != null){ Element annotationEl = serializeAnnotation(doc,
             * complexTypeObj.annotation, schema); serializedComplexType.appendChild(annotationEl); }
             */
        }

        if (complexTypeObj.isMixed()) {
            serializedComplexType.setAttribute("mixed", "true");
        }
        if (complexTypeObj.isAbstract()) {
            serializedComplexType.setAttribute("abstract", "true");
        }
        if (complexTypeObj.getId() != null) {
            serializedComplexType.setAttribute("id", complexTypeObj.getId());
        }

        if (complexTypeObj.getAnnotation() != null) {
            Element annotationEl = serializeAnnotation(doc, complexTypeObj.getAnnotation(), schema);
            serializedComplexType.appendChild(annotationEl);
        }

        if (complexTypeObj.getContentModel() instanceof XmlSchemaSimpleContent) {
            Element simpleContent = serializeSimpleContent(
                                                           doc,
                                                           (XmlSchemaSimpleContent)
                                                           complexTypeObj.getContentModel(),
                                                           schema);
            serializedComplexType.appendChild(simpleContent);
        } else if (complexTypeObj.getContentModel() instanceof XmlSchemaComplexContent) {

            Element complexContent = serializeComplexContent(
                                                             doc,
                                                             (XmlSchemaComplexContent)
                                                             complexTypeObj.getContentModel(),
                                                             schema);
            serializedComplexType.appendChild(complexContent);
        }

        if (complexTypeObj.getParticle() instanceof XmlSchemaSequence) {
            Element sequence = serializeSequence(doc,
                                                 (XmlSchemaSequence)complexTypeObj.getParticle(), schema);
            serializedComplexType.appendChild(sequence);
        } else if (complexTypeObj.getParticle() instanceof XmlSchemaChoice) {
            Element choice = serializeChoice(doc, (XmlSchemaChoice)complexTypeObj.getParticle(), schema);
            serializedComplexType.appendChild(choice);
        } else if (complexTypeObj.getParticle() instanceof XmlSchemaAll) {
            Element all = serializeAll(doc, (XmlSchemaAll)complexTypeObj.getParticle(), schema);
            serializedComplexType.appendChild(all);
        } else if (complexTypeObj.getParticle() instanceof XmlSchemaGroupRef) {
            Element group = serializeGroupRef(doc, (XmlSchemaGroupRef)complexTypeObj.getParticle(), schema);
            serializedComplexType.appendChild(group);
        }

        if (complexTypeObj.getBlock() != null
            && complexTypeObj.getBlock() != XmlSchemaDerivationMethod.NONE) {
            serializedComplexType.setAttribute("block", complexTypeObj.toString());
        }

        if (complexTypeObj.getFinalDerivation() != null
            && complexTypeObj.getFinalDerivation() != XmlSchemaDerivationMethod.NONE) {
            serializedComplexType.setAttribute("final", complexTypeObj.getFinalDerivation().toString());
        }

        List<XmlSchemaAttributeOrGroupRef> attrColl = complexTypeObj.getAttributes();
        if (attrColl.size() > 0) {
            setupAttr(doc, attrColl, schema, serializedComplexType);
        }

        XmlSchemaAnyAttribute anyAttribute = complexTypeObj.getAnyAttribute();
        if (anyAttribute != null) {
            serializedComplexType.appendChild(serializeAnyAttribute(doc, anyAttribute, schema));
        }

        // process extension
        processExtensibilityComponents(complexTypeObj, serializedComplexType);

        return serializedComplexType;
    }