Element serializeGroup()

in src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java [1222:1258]


    Element serializeGroup(Document doc, XmlSchemaGroup groupObj, XmlSchema schema)
        throws XmlSchemaSerializerException {

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

        if (!groupObj.isAnonymous()) {
            String grpName = groupObj.getName();
            if (grpName.length() > 0) {
                group.setAttribute("name", grpName);
            }
        } else {
            throw new XmlSchemaSerializerException("Group must have " + "name or ref");
        }

        /* annotations are supposed to be written first!!!!! */
        if (groupObj.getAnnotation() != null) {
            Element annotation = serializeAnnotation(doc, groupObj.getAnnotation(), schema);
            group.appendChild(annotation);
        }

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

        // process extension
        processExtensibilityComponents(groupObj, group);

        return group;
    }