Search in sources :

Example 61 with XmlSchemaType

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

the class WSDLToCorbaHelper method processSimpleContentStruct.

protected Struct processSimpleContentStruct(XmlSchemaSimpleContent simpleContent, QName defaultName, Struct corbaStruct, QName schematypeName) throws Exception {
    List<MemberType> attrMembers = null;
    CorbaType basetype = null;
    String uri;
    if (schematypeName != null) {
        uri = schematypeName.getNamespaceURI();
    } else {
        uri = defaultName.getNamespaceURI();
    }
    if (simpleContent.getContent() instanceof XmlSchemaSimpleContentExtension) {
        XmlSchemaSimpleContentExtension ext = (XmlSchemaSimpleContentExtension) simpleContent.getContent();
        if (ext.getBaseTypeName() != null) {
            basetype = processPrimitiveType(ext.getBaseTypeName());
        }
        if (basetype == null) {
            XmlSchemaType base = getSchemaType(ext.getBaseTypeName());
            basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
        }
        if (basetype == null) {
            return null;
        }
        // process ext types ????
        MemberType basemember = new MemberType();
        basemember.setName("_simpleTypeValue");
        QName baseTypeName = checkPrefix(basetype.getQName());
        basemember.setIdltype(baseTypeName);
        corbaStruct.getMember().add(basemember);
        if (!isDuplicate(basetype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(basetype);
        }
        attrMembers = processAttributesAsMembers(ext.getAttributes(), uri);
    } else if (simpleContent.getContent() instanceof XmlSchemaSimpleContentRestriction) {
        XmlSchemaSimpleContentRestriction restrict = (XmlSchemaSimpleContentRestriction) simpleContent.getContent();
        if (restrict.getBaseTypeName() != null) {
            basetype = processPrimitiveType(restrict.getBaseTypeName());
        }
        if (basetype == null) {
            XmlSchemaType base = getSchemaType(restrict.getBaseTypeName());
            basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
        }
        MemberType basemember = new MemberType();
        basemember.setName("_simpleTypeValue");
        QName baseTypeName = checkPrefix(basetype.getQName());
        basemember.setIdltype(baseTypeName);
        corbaStruct.getMember().add(basemember);
        if (!isDuplicate(basetype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(basetype);
        }
        attrMembers = processAttributesAsMembers(restrict.getAttributes(), uri);
    }
    // Deal with Attributes defined in Extension
    if (attrMembers != null) {
        for (int i = 0; i < attrMembers.size(); i++) {
            MemberType member = attrMembers.get(i);
            corbaStruct.getMember().add(member);
        }
    }
    return corbaStruct;
}
Also used : XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaSimpleContentRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction)

Example 62 with XmlSchemaType

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

the class WSDLToCorbaHelper method processElementType.

private CorbaType processElementType(XmlSchemaElement stype, QName defaultName, String uri) throws Exception {
    String name = null;
    QName schemaTypeName = null;
    XmlSchemaType schemaType = stype.getSchemaType();
    if (stype.getQName() == null) {
        if (stype.getRef().getTargetQName() == null) {
            schemaTypeName = defaultName;
        } else {
            name = stype.getRef().getTargetQName().getLocalPart();
            schemaType = findSchemaType(stype.getRef().getTargetQName());
        }
    } else {
        name = stype.getQName().getLocalPart();
    }
    if (schemaTypeName == null) {
        schemaTypeName = createQNameTargetNamespace(name);
    }
    CorbaType result = convertSchemaToCorbaType(schemaType, schemaTypeName, schemaType, null, false);
    result.setQualified(getElementQualification(stype, uri));
    return result;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 63 with XmlSchemaType

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

the class UnionVisitor method processCaseNodes.

private void processCaseNodes(AST caseNode, Scope scope, XmlSchemaChoice choice, Union corbaUnion) {
    while (caseNode != null) {
        final AST typeNode;
        final AST nameNode;
        // xmlschema:element
        XmlSchemaElement element = new XmlSchemaElement(schema, false);
        // corba:unionbranch
        Unionbranch unionBranch = new Unionbranch();
        if (caseNode.getType() == IDLTokenTypes.LITERAL_default) {
            // default:
            unionBranch.setDefault(true);
            typeNode = caseNode.getFirstChild();
            nameNode = typeNode.getNextSibling();
        } else {
            // case:
            createCase(caseNode, unionBranch);
            AST labelNode = caseNode.getFirstChild();
            if (labelNode.getType() == IDLTokenTypes.LITERAL_case) {
                labelNode = labelNode.getNextSibling();
            }
            typeNode = labelNode.getNextSibling();
            nameNode = typeNode.getNextSibling();
        }
        TypesVisitor visitor = new TypesVisitor(scope, definition, schema, wsdlVisitor, null);
        visitor.visit(typeNode);
        XmlSchemaType stype = visitor.getSchemaType();
        CorbaType ctype = visitor.getCorbaType();
        Scope fullyQualifiedName = visitor.getFullyQualifiedName();
        // needed for anonymous arrays in unions
        if (ArrayVisitor.accept(nameNode)) {
            Scope anonScope = new Scope(scope, TypesUtils.getCorbaTypeNameNode(nameNode));
            ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fullyQualifiedName);
            arrayVisitor.setSchemaType(stype);
            arrayVisitor.setCorbaType(ctype);
            arrayVisitor.visit(nameNode);
            stype = arrayVisitor.getSchemaType();
            ctype = arrayVisitor.getCorbaType();
            fullyQualifiedName = visitor.getFullyQualifiedName();
        }
        // xmlschema:element
        element.setName(nameNode.toString());
        if (stype != null) {
            element.setSchemaTypeName(stype.getQName());
            if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
                element.setNillable(true);
            }
        } else {
            UnionDeferredAction elementAction = new UnionDeferredAction(element);
            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
        }
        choice.getItems().add(element);
        // corba:unionbranch
        unionBranch.setName(nameNode.toString());
        if (ctype != null) {
            unionBranch.setIdltype(ctype.getQName());
        } else {
            // its type is forward declared.
            UnionDeferredAction unionBranchAction = new UnionDeferredAction(unionBranch);
            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionBranchAction);
        }
        corbaUnion.getUnionbranch().add(unionBranch);
        caseNode = caseNode.getNextSibling();
    }
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 64 with XmlSchemaType

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

the class WSDLParameter method findSchemaType.

// This willl search the current schemas and any included
// schemas for the schema type.
private static XmlSchemaType findSchemaType(XmlSchema xmlSchema, QName typeName) {
    XmlSchemaType schemaType = xmlSchema.getTypeByName(typeName);
    if (schemaType == null) {
        for (XmlSchemaExternal ext : xmlSchema.getExternals()) {
            if (ext instanceof XmlSchemaImport) {
                XmlSchemaImport xmlImport = (XmlSchemaImport) ext;
                if (xmlImport.getNamespace().equals(typeName.getNamespaceURI())) {
                    XmlSchema importSchema = xmlImport.getSchema();
                    schemaType = importSchema.getTypeByName(typeName);
                } else {
                    schemaType = findSchemaType(ext.getSchema(), typeName);
                    if (schemaType != null) {
                        return schemaType;
                    }
                }
            }
        }
        if (schemaType != null) {
            return schemaType;
        }
    }
    return schemaType;
}
Also used : XmlSchemaExternal(org.apache.ws.commons.schema.XmlSchemaExternal) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 65 with XmlSchemaType

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

the class WSDLToCorbaBinding method addCorbaTypes.

private void addCorbaTypes(XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaType> objs = xmlSchemaTypes.getSchemaTypes();
    for (XmlSchemaType type : objs.values()) {
        boolean anonymous = WSDLTypes.isAnonymous(type.getName());
        CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(type, type.getQName(), null, null, anonymous);
        if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        }
    }
    addCorbaElements(xmlSchemaTypes);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

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