Package org.jibx.schema.elements

Examples of org.jibx.schema.elements.ComplexTypeElement


                    pelem = buildValueElement(parm, ptypemap, typeschemas, holder);
                    seq.getParticleList().add(pelem);
                }
               
                // add corresponding schema definition to schema
                ComplexTypeElement tdef = new ComplexTypeElement();
                tdef.setContentDefinition(seq);
                ElementElement elem = new ElementElement();
                String wname = odef.getRequestWrapperName();
                elem.setName(wname);
                elem.setTypeDefinition(tdef);
                schema.getTopLevelChildren().add(elem);
                rqelem = new QName(sns, wname);
               
            }
           
            // add part definition to message (if present)
            if (rqelem != null) {
                MessagePart part = new MessagePart("part", rqelem);
                rqmsg.getParts().add(part);
                def.addNamespace(rqelem.getUri());
            }
           
            // generate output message information
            Message rsmsg = new Message(odef.getResponseMessageName(), wns);
            op.addOutputMessage(rsmsg);
            def.addMessage(rsmsg);
            ValueCustom rtrn = odef.getReturn();
            QName rselem = null;
            if (m_generationParameters.isDocLit()) {
               
                // check if return value defined for method
                if (!"void".equals(rtrn.getWorkingType())) {
                   
                    // check for existing element definition matching the return type
                    rselem = (QName)classelems.get(rtrn.getWorkingType());
                    if (rselem == null) {
                       
                        // create new element for return
                        ElementElement relem = buildValueElement(rtrn, ptypemap, typeschemas, holder);
                        schema.getTopLevelChildren().add(relem);
                        rselem = relem.getQName();
                       
                    } else {
                       
                        // import and use existing element definition
                        imports.add(elemschemas.get(rselem));
                        addSchemaReference(rqelem, elemschemas, holder);
                       
                    }
                }
               
            } else {
               
                // add corresponding schema definition to schema
                SequenceElement seq = new SequenceElement();
                if (!"void".equals(rtrn.getWorkingType())) {
                    ElementElement relem = buildValueElement(rtrn, ptypemap, typeschemas, holder);
                    seq.getParticleList().add(relem);
                }
                ComplexTypeElement tdef = new ComplexTypeElement();
                tdef.setContentDefinition(seq);
                ElementElement elem = new ElementElement();
                String wname = odef.getResponseWrapperName();
                elem.setName(wname);
                elem.setTypeDefinition(tdef);
                schema.getTopLevelChildren().add(elem);
View Full Code Here


                case SchemaBase.COMPLEXTYPE_TYPE:
                {
                    if (parent.isGlobal()) {
                        GlobalExtension global = (GlobalExtension)parent.getExtension();
                        if (!global.isIncluded() && global.isPreferInline()) {
                            ComplexTypeElement type = (ComplexTypeElement)parent;
                            ComponentExtension typeext = (ComponentExtension)type.getExtension();
                            typeext.setOverrideType(derive.getBase());
                            if (s_logger.isDebugEnabled()) {
                                s_logger.debug(lead + "set substitution for global complex type " +
                                    SchemaUtils.componentPath(type) + " to base type from derivation " +
                                    SchemaUtils.componentPath(childcomp));
                            }
                            return true;
                        }
                    }
                    break;
                }
               
                case SchemaBase.ELEMENT_TYPE:
                {
                    // set the element type to the restriction base
                    ElementElement elem = (ElementElement)parent;
                    elem.setTypeDefinition(derive.getBaseType());
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug(lead + "replaced element " + SchemaUtils.componentPath(elem) +
                            " type with base type from derivation " + SchemaUtils.componentPath(childcomp));
                    }
                    return true;
                }
               
                case SchemaBase.SIMPLETYPE_TYPE:
                {
                    // replace type only if global type definition
                    if (parent.isGlobal()) {
                        GlobalExtension global = (GlobalExtension)parent.getExtension();
                        if (!global.isIncluded()) {
                            SimpleTypeElement type = (SimpleTypeElement)parent;
                            ComponentExtension parentext = (ComponentExtension)type.getExtension();
                            parentext.setOverrideType(derive.getBase());
                            return true;
                        }
                    }
                    break;
View Full Code Here

        } else if (comp instanceof CollectionElement) {
            CollectionElement coll = (CollectionElement)comp;
            if (coll.children().size() > 0) {
               
                // collection with children, choice or sequence from order
                ComplexTypeElement type = new ComplexTypeElement();
                if (coll.isOrdered()) {
                   
                    // ordered children go to sequence element, repeating
                    SequenceElement seq = new SequenceElement();
                    type.setContentDefinition(seq);
                   
                } else {
                   
                    // unordered children go to repeated choice element
                    ChoiceElement choice = new ChoiceElement();
                    type.setContentDefinition(choice);
                   
                }
                type.setContentDefinition(buildCompositor(coll, 0, true, hold));
                elem.setTypeDefinition(type);
               
            } else {
               
                // empty collection, item-type must reference a concrete mapping
                String itype = coll.getItemTypeName();
                TemplateElementBase ref = coll.getDefinitions().getSpecificTemplate(itype);
                if (ref instanceof MappingElement) {
                   
                    // item type with concrete mapping, make it an element
                    MappingDetail detail = m_detailDirectory.getMappingDetail((MappingElementBase)ref);
                    ComplexTypeElement type = new ComplexTypeElement();
                    SequenceElement seq = new SequenceElement();
                    type.setContentDefinition(seq);
                    ElementElement item = new ElementElement();
                    setElementRef(detail.getOtherName(), item, hold);
                    item.setMinOccurs(Count.COUNT_ZERO);
                    item.setMaxOccurs(Count.COUNT_UNBOUNDED);
                    seq.getParticleList().add(item);
                    elem.setTypeDefinition(type);
                    addItemDocumentation(coll, item);
                   
                } else {
                   
                    // TODO: handle this with xs:any strict?
                    m_context.addWarning("Handling not implemented for unspecified mapping", coll);
                }
               
            }
        } else {
           
            // must be a structure, check children
            StructureElement struct = (StructureElement)comp;
            if (struct.children().size() > 0) {
               
                // structure with children, choice or sequence from order
                ComplexTypeElement type = new ComplexTypeElement();
                if (struct.isOrdered()) {
                   
                    // ordered children go to sequence element
                    SequenceElement seq = new SequenceElement();
                    type.setContentDefinition(seq);
                   
                } else {
                   
                    // unordered children go to repeated choice element
                    ChoiceElement choice = new ChoiceElement();
                    type.setContentDefinition(choice);
                }
                type.setContentDefinition(buildCompositor(struct, 0, false, hold));
                fillAttributes(struct, 0, type.getAttributeList(), hold);
                elem.setTypeDefinition(type);
               
            } else {
               
                // no children, must be a mapping reference
View Full Code Here

     * @return constructed complex type
     */
    private ComplexTypeElement buildComplexType(MappingDetail detail, SchemaHolder hold) {
       
        // create the type and compositor
        ComplexTypeElement type = new ComplexTypeElement();
        MappingElementBase mapping = detail.getMapping();
        MappingElementBase base = detail.getExtensionBase();
        if (base == null) {
            if (detail.isGroup()) {
               
                // create type using references to group and/or attributeGroup
                SequenceElement seq = new SequenceElement();
                if (detail.hasChild()) {
                    GroupRefElement gref = new GroupRefElement();
                    setGroupRef(detail.getOtherName(), gref, hold);
                    seq.getParticleList().add(gref);
                }
                type.setContentDefinition(seq);
                if (detail.hasAttribute()) {
                    AttributeGroupRefElement gref = new AttributeGroupRefElement();
                    setGroupRef(detail.getOtherName(), gref, hold);
                    type.getAttributeList().add(gref);
                }
               
            } else {
               
                // create type directly
                type.setContentDefinition(buildCompositor(mapping, 0, false, hold));
                fillAttributes(mapping, 0, type.getAttributeList(), hold);
               
            }
        } else {
           
            // create type as extension of base type
            MappingDetail basedet = m_detailDirectory.getMappingDetail(base);
            if (isComplexContent(base) || isComplexContent(mapping)) {
               
                // complex extension with complex content
                ComplexExtensionElement ext = new ComplexExtensionElement();
                setComplexExtensionBase(basedet.getTypeName(), ext, hold);
                CommonCompositorDefinition comp = buildCompositor(mapping, 1, false, hold);
                if (comp.getParticleList().size() > 0) {
                    ext.setContentDefinition(comp);
                }
                fillAttributes(mapping, 0, ext.getAttributeList(), hold);
                ComplexContentElement cont = new ComplexContentElement();
                cont.setDerivation(ext);
                type.setContentType(cont);
               
            } else {
               
                // simple extension with simple content
                SimpleExtensionElement ext = new SimpleExtensionElement();
                setSimpleExtensionBase(basedet.getTypeName(), ext, hold);
                fillAttributes(mapping, 0, ext.getAttributeList(), hold);
                SimpleContentElement cont = new SimpleContentElement();
                cont.setDerivation(ext);
                type.setContentType(cont);
               
            }
        }
        return type;
    }
View Full Code Here

        if (detail.isType()) {
           
            // set up the basic definition structure
            QName qname = detail.getTypeName();
            SchemaHolder hold = findSchema(qname.getUri());
            ComplexTypeElement type = buildComplexType(detail, hold);
            type.setName(qname.getName());
            addDocumentation(info, type);
            hold.getSchema().getTopLevelChildren().add(type);
        }
       
        // finish by generating element definition
View Full Code Here

TOP

Related Classes of org.jibx.schema.elements.ComplexTypeElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.