Search in sources :

Example 1 with XmlSchemaAll

use of org.apache.ws.commons.schema.XmlSchemaAll in project cxf by apache.

the class WSDLToCorbaHelper method processContainerAsMembers.

protected List<MemberType> processContainerAsMembers(XmlSchemaParticle particle, QName defaultName, QName schemaTypeName) throws Exception {
    List<MemberType> members = new ArrayList<>();
    Iterator<? extends XmlSchemaObjectBase> iterL = null;
    if (particle instanceof XmlSchemaSequence) {
        XmlSchemaSequence scontainer = (XmlSchemaSequence) particle;
        iterL = scontainer.getItems().iterator();
    } else if (particle instanceof XmlSchemaChoice) {
        XmlSchemaChoice scontainer = (XmlSchemaChoice) particle;
        iterL = scontainer.getItems().iterator();
    } else if (particle instanceof XmlSchemaAll) {
        XmlSchemaAll acontainer = (XmlSchemaAll) particle;
        iterL = acontainer.getItems().iterator();
    } else {
        LOG.warning("Unknown particle type " + particle.getClass().getName());
        iterL = new ArrayList<XmlSchemaObjectBase>().iterator();
    }
    while (iterL.hasNext()) {
        XmlSchemaParticle container = (XmlSchemaParticle) iterL.next();
        if (container instanceof XmlSchemaSequence) {
            XmlSchemaSequence sequence = (XmlSchemaSequence) container;
            CorbaType memberType = processSequenceType(sequence, defaultName, schemaTypeName);
            QName typeName = memberType.getQName();
            if (memberType instanceof Struct && !isDuplicate(memberType)) {
                typeMappingType.getStructOrExceptionOrUnion().add(memberType);
            }
            MemberType member = new MemberType();
            member.setName(memberType.getName() + "_f");
            member.setIdltype(typeName);
            member.setAnonschematype(true);
            if (memberType.isSetQualified() && memberType.isQualified()) {
                member.setQualified(true);
            }
            members.add(member);
        } else if (container instanceof XmlSchemaChoice) {
            XmlSchemaChoice choice = (XmlSchemaChoice) container;
            MemberType member = processChoiceMember(choice, defaultName, schemaTypeName);
            member.setAnonschematype(true);
            members.add(member);
        } else if (container instanceof XmlSchemaAll) {
            XmlSchemaAll all = (XmlSchemaAll) container;
            MemberType member = processAllMember(all, defaultName, schemaTypeName);
            member.setAnonschematype(true);
            members.add(member);
        } else if (container instanceof XmlSchemaElement) {
            XmlSchemaElement element = (XmlSchemaElement) container;
            CorbaType corbatype = processLocalElement(defaultName, element, schemaTypeName.getNamespaceURI());
            QName elName = element.getQName();
            if (elName == null) {
                elName = element.getRef().getTargetQName();
            }
            if (corbatype != null) {
                MemberType member;
                String memberName = elName.getLocalPart();
                member = new MemberType();
                member.setName(memberName);
                member.setIdltype(corbatype.getQName());
                if (corbatype.isSetQualified() && corbatype.isQualified()) {
                    member.setQualified(true);
                }
                members.add(member);
            } else {
                LOG.log(Level.WARNING, "Unsupported Element Found in CORBA Binding Generation:" + elName);
            }
        }
    }
    return members;
}
Also used : QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) ArrayList(java.util.ArrayList) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) Struct(org.apache.cxf.binding.corba.wsdl.Struct) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice)

Example 2 with XmlSchemaAll

use of org.apache.ws.commons.schema.XmlSchemaAll in project cxf by apache.

the class SchemaCollection method addCrossImportsType.

private void addCrossImportsType(XmlSchema schema, XmlSchemaType schemaType) {
    // the base type might cross schemas.
    if (schemaType instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaType;
        XmlSchemaUtils.addImportIfNeeded(schema, complexType.getBaseSchemaTypeName());
        addCrossImports(schema, complexType.getContentModel());
        addCrossImportsAttributeList(schema, complexType.getAttributes());
        if (complexType.getParticle() instanceof XmlSchemaChoice) {
            XmlSchemaChoice choice = (XmlSchemaChoice) complexType.getParticle();
            addCrossImports(schema, choice);
        } else if (complexType.getParticle() instanceof XmlSchemaAll) {
            XmlSchemaAll all = (XmlSchemaAll) complexType.getParticle();
            addCrossImports(schema, all);
        } else if (complexType.getParticle() instanceof XmlSchemaSequence) {
            XmlSchemaSequence sequence = (XmlSchemaSequence) complexType.getParticle();
            addCrossImports(schema, sequence);
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 3 with XmlSchemaAll

use of org.apache.ws.commons.schema.XmlSchemaAll in project cxf by apache.

the class SchemaCollection method addCrossImports.

private void addCrossImports(XmlSchema schema, XmlSchemaContentModel contentModel) {
    if (contentModel == null) {
        return;
    }
    XmlSchemaContent content = contentModel.getContent();
    if (content == null) {
        return;
    }
    if (content instanceof XmlSchemaComplexContentExtension) {
        XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
        XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
        addCrossImportsAttributeList(schema, extension.getAttributes());
        XmlSchemaParticle particle = extension.getParticle();
        if (particle instanceof XmlSchemaSequence) {
            addCrossImports(schema, (XmlSchemaSequence) particle);
        } else if (particle instanceof XmlSchemaChoice) {
            addCrossImports(schema, (XmlSchemaChoice) particle);
        } else if (particle instanceof XmlSchemaAll) {
            addCrossImports(schema, (XmlSchemaAll) particle);
        }
    } else if (content instanceof XmlSchemaComplexContentRestriction) {
        XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
        XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
        addCrossImportsAttributeList(schema, restriction.getAttributes());
    } else if (content instanceof XmlSchemaSimpleContentExtension) {
        XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension) content;
        XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
        addCrossImportsAttributeList(schema, extension.getAttributes());
    } else if (content instanceof XmlSchemaSimpleContentRestriction) {
        XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) content;
        XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
        addCrossImportsAttributeList(schema, restriction.getAttributes());
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaContent(org.apache.ws.commons.schema.XmlSchemaContent) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaComplexContentRestriction(org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaSimpleContentRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction)

Example 4 with XmlSchemaAll

use of org.apache.ws.commons.schema.XmlSchemaAll in project wso2-axis2-transports by wso2.

the class XMPPSender method getParameterListForOperation.

/**
 * Retrieves list of parameter names & their type for a given operation
 * @param operation
 */
private static String getParameterListForOperation(AxisOperation operation) {
    // Logic copied from BuilderUtil.buildsoapMessage(...)
    StringBuffer paramList = new StringBuffer();
    AxisMessage axisMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    XmlSchemaElement xmlSchemaElement = axisMessage.getSchemaElement();
    if (xmlSchemaElement != null) {
        XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
        if (schemaType instanceof XmlSchemaComplexType) {
            XmlSchemaComplexType complexType = ((XmlSchemaComplexType) schemaType);
            XmlSchemaParticle particle = complexType.getParticle();
            if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) {
                XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) particle;
                Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();
                while (iterator.hasNext()) {
                    XmlSchemaElement innerElement = (XmlSchemaElement) iterator.next();
                    QName qName = innerElement.getQName();
                    if (qName == null && innerElement.getSchemaTypeName().equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
                        break;
                    }
                    long minOccurs = innerElement.getMinOccurs();
                    boolean nillable = innerElement.isNillable();
                    String name = qName != null ? qName.getLocalPart() : innerElement.getName();
                    String type = innerElement.getSchemaTypeName().toString();
                    paramList.append("," + type + " " + name);
                }
            }
        }
    }
    // remove first ","
    String list = paramList.toString();
    return list.replaceFirst(",", "");
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) Iterator(java.util.Iterator) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) AxisMessage(org.apache.axis2.description.AxisMessage)

Example 5 with XmlSchemaAll

use of org.apache.ws.commons.schema.XmlSchemaAll in project cxf by apache.

the class WSDLToCorbaHelper method processComplexContentStructParticle.

private Struct processComplexContentStructParticle(XmlSchemaParticle extype, QName defaultName, Struct corbaStruct, QName schematypeName, QName extName, List<XmlSchemaAttributeOrGroupRef> list) throws Exception {
    String uri;
    if (schematypeName != null) {
        uri = schematypeName.getNamespaceURI();
    } else {
        uri = defaultName.getNamespaceURI();
    }
    // Add base as a member of this struct
    MemberType memberType = new MemberType();
    memberType.setName(extName.getLocalPart() + "_f");
    if (extName.getLocalPart().equals("anyType")) {
        memberType.setIdltype(processPrimitiveType(extName).getQName());
    } else {
        memberType.setIdltype(createQNameCorbaNamespace(extName.getLocalPart()));
    }
    corbaStruct.getMember().add(memberType);
    // process attributes at complexContent level
    List<MemberType> attlist1 = processAttributesAsMembers(list, uri);
    for (int i = 0; i < attlist1.size(); i++) {
        MemberType member = attlist1.get(i);
        corbaStruct.getMember().add(member);
    }
    // Process members of Current Type
    if (extype instanceof XmlSchemaChoice) {
        XmlSchemaChoice choice = (XmlSchemaChoice) extype;
        MemberType choicemem = processComplexContentStructChoice(choice, schematypeName, defaultName);
        choicemem.setAnonschematype(true);
        corbaStruct.getMember().add(choicemem);
    } else if (extype instanceof XmlSchemaSequence) {
        XmlSchemaSequence seq = (XmlSchemaSequence) extype;
        corbaStruct = processComplexContentStructSequence(corbaStruct, seq, defaultName, schematypeName);
    } else if (extype instanceof XmlSchemaAll) {
        XmlSchemaAll all = (XmlSchemaAll) extype;
        corbaStruct = processComplexContentStructSchemaAll(corbaStruct, all, defaultName, schematypeName);
    }
    return corbaStruct;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice)

Aggregations

XmlSchemaAll (org.apache.ws.commons.schema.XmlSchemaAll)8 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)7 XmlSchemaChoice (org.apache.ws.commons.schema.XmlSchemaChoice)6 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)5 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)3 QName (javax.xml.namespace.QName)2 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)2 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)2 XmlSchemaComplexContentRestriction (org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction)2 XmlSchemaContent (org.apache.ws.commons.schema.XmlSchemaContent)2 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)2 XmlSchemaSimpleContentExtension (org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension)2 XmlSchemaSimpleContentRestriction (org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 AxisMessage (org.apache.axis2.description.AxisMessage)1 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)1 Struct (org.apache.cxf.binding.corba.wsdl.Struct)1 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)1 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)1