Search in sources :

Example 26 with XmlSchemaType

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

the class WSDLToCorbaHelper method findTypeInSchema.

private XmlSchemaType findTypeInSchema(XmlSchema xmlSchema, QName typeName) {
    XmlSchemaType schemaType = null;
    if (xmlSchema.getElementByName(typeName) != null) {
        XmlSchemaElement schemaElement = xmlSchema.getElementByName(typeName);
        schemaType = schemaElement.getSchemaType();
    } else if (xmlSchema.getTypeByName(typeName) != null) {
        schemaType = xmlSchema.getTypeByName(typeName);
    }
    if (schemaType != null) {
        return schemaType;
    }
    for (XmlSchemaExternal extSchema : xmlSchema.getExternals()) {
        if (!(extSchema instanceof XmlSchemaImport)) {
            schemaType = findTypeInSchema(extSchema.getSchema(), typeName);
            if (schemaType != null) {
                return schemaType;
            }
        }
    }
    return null;
}
Also used : XmlSchemaExternal(org.apache.ws.commons.schema.XmlSchemaExternal) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 27 with XmlSchemaType

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

the class WSDLToCorbaHelper method processSimpleType.

private CorbaType processSimpleType(XmlSchemaSimpleType stype, QName defaultName, boolean anonymous) throws Exception {
    CorbaType corbaTypeImpl = null;
    QName name;
    QName schematypeName;
    if (stype.getQName() == null) {
        schematypeName = defaultName;
        name = createQNameTargetNamespace(defaultName.getLocalPart() + "Type");
    } else {
        schematypeName = checkPrefix(stype.getQName());
        if (schematypeName == null) {
            schematypeName = stype.getQName();
        }
        name = createQNameCorbaNamespace(schematypeName.getLocalPart());
    }
    if (stype.getParent().getTargetNamespace().equals(W3CConstants.NU_SCHEMA_XSD)) {
        // built in types
        QName stypeName = createQNameXmlSchemaNamespace(stype.getName());
        corbaTypeImpl = getLocalType(stypeName);
    } else if (stype.getContent() instanceof XmlSchemaSimpleTypeRestriction) {
        corbaTypeImpl = processSimpleRestrictionType(stype, name, schematypeName, anonymous);
    } else if (stype.getContent() instanceof XmlSchemaSimpleTypeList) {
        XmlSchemaSimpleTypeList ltype = (XmlSchemaSimpleTypeList) stype.getContent();
        CorbaType itemType;
        if (ltype.getItemType() != null) {
            itemType = convertSchemaToCorbaType(ltype.getItemType(), name, stype, null, false);
            if (itemType != null) {
                return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false);
            }
            return itemType;
        }
        QName ltypeName = createQNameXmlSchemaNamespace(ltype.getItemTypeName().getLocalPart());
        itemType = processPrimitiveType(ltypeName);
        if (itemType != null) {
            return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false);
        }
        // if the type of the simpleContent is a list with another simple type.
        XmlSchemaType base = getSchemaType(ltype.getItemTypeName());
        itemType = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
        if (itemType != null) {
            return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false);
        }
    } else if (stype.getContent() == null) {
        // elements primitive type
        QName stypeName = createQNameXmlSchemaNamespace(stype.getName());
        corbaTypeImpl = getLocalType(stypeName);
    } else {
        System.out.println("SimpleType Union Not Supported in CORBA Binding");
    }
    return corbaTypeImpl;
}
Also used : XmlSchemaSimpleTypeList(org.apache.ws.commons.schema.XmlSchemaSimpleTypeList) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 28 with XmlSchemaType

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

the class ObjectReferenceVisitor method visitForwardDeclaredObjectReference.

protected void visitForwardDeclaredObjectReference(Scope scope, XmlSchemaCollection schemas, XmlSchema schema, AST node, ScopeNameCollection scopedNames, WSDLASTVisitor wsdlVisitor) {
    XmlSchemaType result = null;
    Scope currentScope = scope;
    // checks from innermost local scope outwards
    if ((node.getFirstChild() == null) || (node.getFirstChild() != null && node.getFirstChild().getType() != IDLTokenTypes.SCOPEOP)) {
        while (result == null && currentScope != currentScope.getParent()) {
            final Scope scopedName;
            if (ScopedNameVisitor.isFullyScopedName(node)) {
                scopedName = ScopedNameVisitor.getFullyScopedName(currentScope, node);
            } else {
                scopedName = new Scope(currentScope, node);
            }
            if (scopedNames.getScope(scopedName) != null) {
                XmlSchema wsaSchema = null;
                // check whether a schema with the required namespace has already been created
                XmlSchema[] existingSchemas = schemas.getXmlSchemas();
                for (XmlSchema xs : existingSchemas) {
                    if (xs.getTargetNamespace().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
                        // if it has been created, reuse it
                        wsaSchema = xs;
                        result = wsaSchema.getTypeByName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
                        break;
                    }
                }
                // if not, create a new one and create the WS-Addressing EndpointReferenceType
                if (wsaSchema == null) {
                    wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
                    XmlSchemaType wsaType = new XmlSchemaType(wsaSchema, false) {
                    };
                    wsaType.setName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
                    result = wsaType;
                }
            }
            currentScope = currentScope.getParent();
        }
    }
    if (result == null) {
        final Scope scopedName;
        if (ScopedNameVisitor.isFullyScopedName(node)) {
            scopedName = ScopedNameVisitor.getFullyScopedName(new Scope(), node);
        } else {
            scopedName = scope;
        }
        if (scopedNames.getScope(scopedName) != null) {
            XmlSchema wsaSchema = null;
            // check whether a schema with the required namespace has already been created
            XmlSchema[] existingSchemas = schemas.getXmlSchemas();
            for (XmlSchema xs : existingSchemas) {
                if (xs.getTargetNamespace().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
                    // if it has been created, reuse it
                    wsaSchema = xs;
                    result = wsaSchema.getTypeByName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
                    break;
                }
            }
            // if not, create a new one and create the WS-Addressing EndpointReferenceType
            if (wsaSchema == null) {
                wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
                XmlSchemaType wsaType = new XmlSchemaType(wsaSchema, false) {
                };
                wsaType.setName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
                result = wsaType;
            }
        }
    }
    setSchemaType(result);
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 29 with XmlSchemaType

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

the class ObjectReferenceVisitor method visitDefaultTypeObjectReference.

private void visitDefaultTypeObjectReference(AST node) {
    // Even though we don't need to add a schema definition for a default endpoint
    // type, we still need to create a schema type so that the visitor knows what
    // kind of parameter this is.  For a default endpoint, we'll just provide a
    // reference to a WS addressing EndpointReferenceType.
    XmlSchema[] scs = schemas.getXmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE);
    XmlSchema wsaSchema = null;
    if (scs != null) {
        for (XmlSchema sc : scs) {
            if (ReferenceConstants.WSADDRESSING_NAMESPACE.equals(sc.getTargetNamespace())) {
                wsaSchema = sc;
                break;
            }
        }
    }
    if (wsaSchema == null) {
        wsaSchema = new XmlSchema(ReferenceConstants.WSADDRESSING_NAMESPACE, schemas);
    }
    XmlSchemaType objectType = new XmlSchemaSimpleType(wsaSchema, true);
    objectType.setName(ReferenceConstants.WSADDRESSING_LOCAL_NAME);
    setSchemaType(objectType);
    // Build and assign the corba:object to the visitor
    Object corbaObject = new Object();
    corbaObject.setQName(new QName(typeMap.getTargetNamespace(), "CORBA.Object"));
    corbaObject.setRepositoryID("IDL:omg.org/CORBA/Object/1.0");
    corbaObject.setType(objectType.getQName());
    setCorbaType(corbaObject);
    // type once.
    if (!isReferenceCORBATypeDefined(corbaObject.getQName())) {
        typeMap.getStructOrExceptionOrUnion().add(corbaObject);
    }
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) Object(org.apache.cxf.binding.corba.wsdl.Object) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 30 with XmlSchemaType

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

the class PrimitiveTypesVisitor method visit.

public void visit(AST node) {
    // <base_type_spec> ::= <floating_pt_type>
    // | <integer_type>
    // | <char_type>
    // | <wide_char_type>
    // | <boolean_type>
    // | <octet_type>
    // | <any_type>
    // | <object_type>      <= NOT SUPPORTED
    // | <value_base_type>  <= NOT SUPPORTED
    // <floating_pt_type> ::= "float"
    // | "double"
    // | "long" double"
    // <integer_type> ::= <signed_int>
    // | <unsigned_int>
    // <signed_int> ::= <signed_short_int>
    // | <signed_long_int>
    // | <signed_longlong_int>
    // <signed_short_int> ::= "short"
    // <signed_long_int> ::= "long"
    // <signed_longlong_int> ::= "long" "long"
    // <unsigned_int> ::= <unsigned_short_int>
    // | <unsigned_long_int>
    // | <unsigned_longlong_int>
    // <unsigned_short_int> ::= "unsigned" "short"
    // <unsigned_long_int> ::= "unsigned" "long"
    // <unsigned_longlong_int> ::= "unsigned" "long" "long"
    // <char_type> ::= "char"
    // <wide_char_type> ::= "wchar"
    // <boolean_type> ::= "boolean"
    // <octet_type> ::= "octet"
    // <any_type> ::= "any"
    XmlSchemaType stype = null;
    CorbaType ctype = null;
    QName corbaTypeQName = PrimitiveTypesVisitor.getPrimitiveType(node);
    if (corbaTypeQName != null) {
        QName schemaTypeQName = xmlSchemaPrimitiveMap.get(corbaTypeQName);
        if (schemaTypeQName != null) {
            // XmlSchemaCollection schemas = new XmlSchemaCollection();
            stype = schemas.getTypeByQName(schemaTypeQName);
            if (stype != null) {
                ctype = new CorbaType();
                ctype.setQName(corbaTypeQName);
                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)

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