Search in sources :

Example 31 with XmlSchemaType

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

the class ScopedNameVisitor method populateAliasSchemaType.

protected static void populateAliasSchemaType(CorbaType corbaType, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    holder.setCorbaType(corbaType);
    Alias alias = (Alias) corbaType;
    // loop through alias base types, till you get a non-alias corba type
    CorbaType type = findCorbaType(typeMap, alias.getBasetype());
    while ((type != null) && (type instanceof Alias)) {
        alias = (Alias) type;
        type = findCorbaType(typeMap, alias.getBasetype());
    }
    QName tname;
    if (type == null) {
        // it must be a primitive type
        tname = xmlSchemaPrimitiveMap.get(alias.getBasetype());
    } else {
        tname = type.getType();
    }
    XmlSchemaType stype = schemas.getTypeByQName(tname);
    if (stype == null) {
        XmlSchema xmlSchema = wsdlVisitor.getManager().getXmlSchema(tname.getNamespaceURI());
        if (xmlSchema != null) {
            stype = xmlSchema.getTypeByName(tname);
        } else {
            stype = wsdlVisitor.getSchema().getTypeByName(tname);
        }
    }
    holder.setSchemaType(stype);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Alias(org.apache.cxf.binding.corba.wsdl.Alias) QName(javax.xml.namespace.QName) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection)

Example 32 with XmlSchemaType

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

the class ScopedNameVisitor method visit.

public void visit(AST node) {
    // <scoped_name> ::= <identifier>
    // | :: <identifier>
    // | <scoped_name> "::" <identifier>
    XmlSchemaType stype = null;
    CorbaType ctype = null;
    if (PrimitiveTypesVisitor.accept(node)) {
        // primitive type
        PrimitiveTypesVisitor primitiveVisitor = new PrimitiveTypesVisitor(null, definition, schema, schemas);
        primitiveVisitor.visit(node);
        stype = primitiveVisitor.getSchemaType();
        ctype = primitiveVisitor.getCorbaType();
    } else if (isforwardDeclared(getScope(), node, wsdlVisitor)) {
        // forward declaration
        Scope scope = forwardDeclared(getScope(), definition, schema, node, wsdlVisitor);
        setFullyQualifiedName(scope);
    // how will we create the corbatype ????
    } else if (ObjectReferenceVisitor.accept(getScope(), schema, definition, node, wsdlVisitor)) {
        ObjectReferenceVisitor objRefVisitor = new ObjectReferenceVisitor(getScope(), definition, schema, wsdlVisitor);
        objRefVisitor.visit(node);
        stype = objRefVisitor.getSchemaType();
        ctype = objRefVisitor.getCorbaType();
    } else {
        VisitorTypeHolder holder = new VisitorTypeHolder();
        boolean found = findSchemaType(getScope(), definition, schema, node, wsdlVisitor, holder);
        if (found) {
            ctype = holder.getCorbaType();
            stype = holder.getSchemaType();
        } else {
            Scope scopedName = new Scope(getScope(), node);
            QName qname = new QName(schema.getTargetNamespace(), scopedName.toString());
            throw new RuntimeException("[ScopedNameVisitor:  Corba type " + qname + " not found in typeMap]");
        }
    }
    setSchemaType(stype);
    setCorbaType(ctype);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 33 with XmlSchemaType

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

the class ScopedNameVisitor method findScopeSchemaType.

// Searches this scope for the schema type.
private static boolean findScopeSchemaType(Scope scopedName, XmlSchema schemaRef, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    ModuleToNSMapper mapper = wsdlVisitor.getModuleToNSMapper();
    WSDLSchemaManager manager = wsdlVisitor.getManager();
    boolean result = findNonSchemaType(scopedName.toString(), wsdlVisitor, holder);
    if (!result) {
        XmlSchema xmlSchema = schemaRef;
        String tns = wsdlVisitor.getModuleToNSMapper().map(scopedName.getParent());
        if (tns != null) {
            xmlSchema = wsdlVisitor.getManager().getXmlSchema(tns);
        }
        XmlSchemaType stype = null;
        if (xmlSchema != null) {
            // Exceptions are treated as a special case as for the
            // doc/literal style
            // in the schema we will have an element and a complextype
            // so the name
            // and the typename will be different.
            final String scopedNameString;
            if (mapper.isDefaultMapping()) {
                scopedNameString = scopedName.toString();
            } else {
                scopedNameString = scopedName.tail();
            }
            final QName qname;
            if (exceptionMode) {
                qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString + "Type");
            } else {
                qname = new QName(xmlSchema.getTargetNamespace(), scopedNameString);
            }
            stype = xmlSchema.getTypeByName(qname);
            if (stype == null) {
                stype = schemas.getTypeByQName(qname);
            }
        }
        if (stype != null) {
            result = true;
        }
        if (result && holder != null) {
            holder.setSchemaType(stype);
            holder.setCorbaType(getCorbaSchemaType(xmlSchema, typeMap, stype, scopedName));
            // add a xmlschema import
            if (!schemaRef.getTargetNamespace().equals(xmlSchema.getTargetNamespace())) {
                String importFile = wsdlVisitor.getOutputDir() + System.getProperty("file.separator") + scopedName.getParent().toString("_");
                manager.addXmlSchemaImport(schemaRef, xmlSchema, importFile);
            }
        }
    }
    return result;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) QName(javax.xml.namespace.QName) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection)

Example 34 with XmlSchemaType

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

the class FixedPtConstVisitor method visit.

public void visit(AST fixedNode) {
    // <fixed_pt_const_type> ::= "fixed"
    CorbaType ctype = null;
    QName schemaTypeQName = Constants.XSD_DECIMAL;
    XmlSchemaType stype = schemas.getTypeByQName(schemaTypeQName);
    if (stype != null) {
        ctype = new CorbaType();
        ctype.setQName(CorbaConstants.NE_CORBA_FIXED);
        ctype.setType(stype.getQName());
        ctype.setName(stype.getQName().getLocalPart());
    }
    schemaType = stype;
    corbaType = ctype;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 35 with XmlSchemaType

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

the class StructVisitor method visitStructMembers.

private void visitStructMembers(AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) {
    AST memberTypeNode = identifierNode.getNextSibling();
    while (memberTypeNode != null) {
        AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
        final XmlSchemaType schemaType;
        final CorbaType corbaType;
        Scope fqName;
        try {
            TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null);
            visitor.visit(memberTypeNode);
            schemaType = visitor.getSchemaType();
            corbaType = visitor.getCorbaType();
            fqName = visitor.getFullyQualifiedName();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        // (hence the ScopedNameVisitor.accept() call).
        while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor, true)) {
            XmlSchemaType memberSchemaType = schemaType;
            CorbaType memberCorbaType = corbaType;
            // needed for anonymous arrays in structs
            if (ArrayVisitor.accept(memberNode)) {
                Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
                ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName);
                arrayVisitor.setSchemaType(schemaType);
                arrayVisitor.setCorbaType(corbaType);
                arrayVisitor.visit(memberNode);
                memberSchemaType = arrayVisitor.getSchemaType();
                memberCorbaType = arrayVisitor.getCorbaType();
                fqName = arrayVisitor.getFullyQualifiedName();
            }
            XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName);
            sequence.getItems().add(member);
            MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName);
            struct.getMember().add(memberType);
            memberNode = memberNode.getNextSibling();
        }
        memberTypeNode = memberNode;
    }
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) 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