Search in sources :

Example 76 with XmlSchemaType

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

the class TypesUtils method generateAnonymousScopedName.

public static Scope generateAnonymousScopedName(Scope scope, XmlSchema schema) {
    Scope scopedName;
    XmlSchemaType anonSchemaType;
    int id = 0;
    do {
        id++;
        StringBuilder name = new StringBuilder();
        name.append('_');
        name.append("Anon").append(Integer.toString(id));
        name.append('_');
        name.append(scope.tail());
        scopedName = new Scope(scope.getParent(), name.toString());
        QName scopedQName = new QName(schema.getTargetNamespace(), scopedName.toString());
        anonSchemaType = schema.getTypeByName(scopedQName);
    } while (anonSchemaType != null);
    return scopedName;
}
Also used : QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 77 with XmlSchemaType

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

the class ProcessorUtil method createWrappedElementsFromExtension.

private static List<WrapperElement> createWrappedElementsFromExtension(SchemaCollection schema, XmlSchemaComplexType type, int maxStackDepth) {
    List<WrapperElement> qnames = new ArrayList<>();
    XmlSchemaContent schemaContent = type.getContentModel().getContent();
    if (!(schemaContent instanceof XmlSchemaComplexContentExtension) || maxStackDepth == 0) {
        return qnames;
    }
    XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) schemaContent;
    QName baseTypeName = extension.getBaseTypeName();
    XmlSchemaType baseType = schema.getTypeByQName(baseTypeName);
    if (baseType instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexBaseType = (XmlSchemaComplexType) baseType;
        if (complexBaseType.getParticle() == null && complexBaseType.getContentModel() != null) {
            // continue up the extension ladder
            qnames.addAll(createWrappedElementsFromExtension(schema, complexBaseType, maxStackDepth - 1));
        } else if (complexBaseType.getParticle() instanceof XmlSchemaSequence) {
            XmlSchemaSequence seq = (XmlSchemaSequence) complexBaseType.getParticle();
            qnames.addAll(createWrappedElements(seq));
        }
    }
    if (extension.getParticle() instanceof XmlSchemaSequence) {
        XmlSchemaSequence xmlSchemaSeq = (XmlSchemaSequence) extension.getParticle();
        qnames.addAll(createWrappedElements(xmlSchemaSeq));
    }
    return qnames;
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) QName(javax.xml.namespace.QName) XmlSchemaContent(org.apache.ws.commons.schema.XmlSchemaContent) ArrayList(java.util.ArrayList) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 78 with XmlSchemaType

use of org.apache.ws.commons.schema.XmlSchemaType 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 79 with XmlSchemaType

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

the class ReflectionServiceFactoryBean method fillInSchemaCrossreferences.

/**
 * Code elsewhere in this function will fill in the name of the type of an
 * element but not the reference to the type. This function fills in the
 * type references. This does not set the type reference for elements that
 * are declared as refs to other elements. It is a giant pain to find them,
 * since they are not (generally) root elements and the code would have to
 * traverse all the types to find all of them. Users should look them up
 * through the collection, that's what it is for.
 */
private void fillInSchemaCrossreferences() {
    Service service = getService();
    for (ServiceInfo serviceInfo : service.getServiceInfos()) {
        SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();
        // type.
        for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
            Map<QName, XmlSchemaElement> elementsTable = schemaInfo.getSchema().getElements();
            for (XmlSchemaElement element : elementsTable.values()) {
                if (element.getSchemaType() == null) {
                    QName typeName = element.getSchemaTypeName();
                    if (typeName != null) {
                        XmlSchemaType type = schemaCollection.getTypeByQName(typeName);
                        if (type == null) {
                            Message message = new Message("REFERENCE_TO_UNDEFINED_TYPE", LOG, element.getQName(), typeName, service.getName());
                            LOG.severe(message.toString());
                        } else {
                            element.setSchemaType(type);
                        }
                    }
                }
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Message(org.apache.cxf.common.i18n.Message) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Service(org.apache.cxf.service.Service) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Example 80 with XmlSchemaType

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

the class ReflectionServiceFactoryBean method checkForElement.

protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
    SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(), getQualifyWrapperSchema());
    XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart());
    if (e != null) {
        mpi.setXmlSchema(e);
        return;
    }
    XmlSchema schema = si.getSchema();
    // cached element is now invalid
    si.setElement(null);
    XmlSchemaElement el = new XmlSchemaElement(schema, true);
    el.setName(mpi.getElementQName().getLocalPart());
    el.setNillable(true);
    XmlSchemaType tp = (XmlSchemaType) mpi.getXmlSchema();
    if (tp == null) {
        throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG, mpi.getName(), mpi.getMessageInfo().getName()));
    }
    el.setSchemaTypeName(tp.getQName());
    mpi.setXmlSchema(el);
}
Also used : Message(org.apache.cxf.common.i18n.Message) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Aggregations

XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)81 QName (javax.xml.namespace.QName)47 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)37 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)23 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)23 XmlSchema (org.apache.ws.commons.schema.XmlSchema)21 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)16 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)12 AST (antlr.collections.AST)8 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)8 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)7 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)6 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)5 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)5 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)5 ArrayList (java.util.ArrayList)4 CorbaTypeImpl (org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl)4 Message (org.apache.cxf.common.i18n.Message)4 ParticleInfo (org.apache.cxf.javascript.ParticleInfo)4 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)4