Search in sources :

Example 36 with XmlSchemaType

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

the class TypedefVisitor method visit.

public void visit(AST typedefNode) {
    // "typedef" <type_declarator>
    // <type_declarator> ::= <type_spec> <declarators>
    AST typeDeclaratorNode = typedefNode.getFirstChild();
    AST identifierNode = TypesUtils.getCorbaTypeNameNode(typeDeclaratorNode);
    TypesVisitor typesVisitor = new TypesVisitor(getScope(), definition, schema, wsdlVisitor, identifierNode);
    typesVisitor.visit(typeDeclaratorNode);
    XmlSchemaType schemaType = typesVisitor.getSchemaType();
    CorbaType corbaType = typesVisitor.getCorbaType();
    Scope fullyQualifiedName = typesVisitor.getFullyQualifiedName();
    Scope typedefScope = new Scope(getScope(), identifierNode);
    if (SequenceVisitor.accept(typeDeclaratorNode) || FixedVisitor.accept(typeDeclaratorNode)) {
        // Handle cases "typedef sequence"
        // "typedef fixed"
        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope, definition, schema, wsdlVisitor, schemaType, corbaType, fullyQualifiedName);
        declaratorVisitor.visit(identifierNode);
    } else if (StringVisitor.accept(typeDeclaratorNode)) {
        if (StringVisitor.isBounded(typeDeclaratorNode) && !wsdlVisitor.getBoundedStringOverride()) {
            DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope, definition, schema, wsdlVisitor, schemaType, corbaType, fullyQualifiedName);
            declaratorVisitor.visit(identifierNode);
        } else {
            while (identifierNode != null) {
                if (ArrayVisitor.accept(identifierNode)) {
                    ArrayVisitor arrayVisitor = new ArrayVisitor(new Scope(getScope(), identifierNode.getText()), definition, schema, wsdlVisitor, identifierNode, fullyQualifiedName);
                    arrayVisitor.setSchemaType(schemaType);
                    arrayVisitor.setCorbaType(corbaType);
                    arrayVisitor.visit(identifierNode);
                } else {
                    generateStringAlias(typeDeclaratorNode, identifierNode, schemaType, corbaType, fullyQualifiedName);
                }
                identifierNode = identifierNode.getNextSibling();
            }
        }
    } else {
        // if declaring an array, do not generate aliases
        if (!ArrayVisitor.accept(identifierNode)) {
            generateAlias(identifierNode, schemaType, corbaType, fullyQualifiedName);
            corbaType = getCorbaType();
        }
        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(typedefScope, definition, schema, wsdlVisitor, schemaType, corbaType, fullyQualifiedName);
        declaratorVisitor.visit(identifierNode);
    }
    setSchemaType(schemaType);
    setCorbaType(corbaType);
    setFullyQualifiedName(fullyQualifiedName);
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 37 with XmlSchemaType

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

the class UnionVisitor method processForwardUnionActions.

// Process any actions that were defered for a forward declared union
private void processForwardUnionActions(Scope unionScope) {
    if (wsdlVisitor.getDeferredActions() != null) {
        DeferredActionCollection deferredActions = wsdlVisitor.getDeferredActions();
        List<DeferredAction> list = deferredActions.getActions(unionScope);
        if ((list != null) && !list.isEmpty()) {
            XmlSchemaType stype = getSchemaType();
            CorbaType ctype = getCorbaType();
            Iterator<DeferredAction> iterator = list.iterator();
            while (iterator.hasNext()) {
                SchemaDeferredAction action = (SchemaDeferredAction) iterator.next();
                action.execute(stype, ctype);
            }
            iterator = list.iterator();
            while (iterator.hasNext()) {
                iterator.next();
                iterator.remove();
            }
        }
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 38 with XmlSchemaType

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

the class PortTypeVisitor method handleDeferredActions.

private void handleDeferredActions(DeferredActionCollection deferredActions, Scope scopedName, AST identifierNode) {
    List<DeferredAction> list = deferredActions.getActions(scopedName);
    if ((list != null) && !list.isEmpty()) {
        XmlSchemaType stype = null;
        CorbaTypeImpl ctype = null;
        if (ObjectReferenceVisitor.accept(getScope(), schema, definition, identifierNode, wsdlVisitor)) {
            ObjectReferenceVisitor visitor = new ObjectReferenceVisitor(getScope(), definition, schema, wsdlVisitor);
            visitor.visit(identifierNode);
            stype = visitor.getSchemaType();
            ctype = visitor.getCorbaType();
        }
        for (DeferredAction action : list) {
            if (action instanceof SchemaDeferredAction && (stype != null) && (ctype != null)) {
                SchemaDeferredAction schemaAction = (SchemaDeferredAction) action;
                schemaAction.execute(stype, ctype);
            }
        }
        deferredActions.removeScope(scopedName);
    }
}
Also used : CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 39 with XmlSchemaType

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

the class ParamDclVisitor method visit.

public void visit(AST node) {
    // <param_dcl> ::= <param_attribute> <param_type_spec> <simple_declarator>
    // <param_attribute> ::= "in"
    // | "out"
    // | "inout"
    AST typeNode = node.getFirstChild();
    AST nameNode = TypesUtils.getCorbaTypeNameNode(typeNode);
    ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), definition, schema, wsdlVisitor);
    visitor.visit(typeNode);
    XmlSchemaType schemaType = visitor.getSchemaType();
    CorbaType corbaType = visitor.getCorbaType();
    Scope fullyQualifiedName = visitor.getFullyQualifiedName();
    switch(node.getType()) {
        case IDLTokenTypes.LITERAL_in:
            addElement(inWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
            addCorbaParam(corbaType, ModeType.IN, nameNode.toString(), fullyQualifiedName);
            break;
        case IDLTokenTypes.LITERAL_out:
            addElement(outWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
            addCorbaParam(corbaType, ModeType.OUT, nameNode.toString(), fullyQualifiedName);
            break;
        case IDLTokenTypes.LITERAL_inout:
            addElement(inWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
            addElement(outWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
            addCorbaParam(corbaType, ModeType.INOUT, nameNode.toString(), fullyQualifiedName);
            break;
        default:
            throw new RuntimeException("[ParamDclVisitor: illegal IDL!]");
    }
    setSchemaType(schemaType);
    setCorbaType(corbaType);
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 40 with XmlSchemaType

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

the class ServiceJavascriptBuilder method getElementType.

/**
 * Follow a chain of references from element to element until we can obtain
 * a type.
 *
 * @param element
 */
public static XmlSchemaType getElementType(SchemaCollection xmlSchemaCollection, String referencingURI, XmlSchemaElement element, XmlSchemaType containingType) {
    assert element != null;
    if (element.getSchemaTypeName() != null) {
        XmlSchemaType type = xmlSchemaCollection.getTypeByQName(element.getSchemaTypeName());
        if (type == null) {
            Message message = new Message("ELEMENT_TYPE_MISSING", LOG, element.getQName(), element.getSchemaTypeName().toString());
            throw new UnsupportedConstruct(message);
        }
        return type;
    }
    // The referencing URI only helps if there is a schema that points to
    // it.
    // It might be the URI for the wsdl TNS, which might have no schema.
    // if (xmlSchemaCollection.getSchemaByTargetNamespace(referencingURI) == null) {
    // referencingURI = null;
    // }
    // 
    // if (referencingURI == null && containingType != null) {
    // referencingURI = containingType.getQName().getNamespaceURI();
    // }
    XmlSchemaElement originalElement = element;
    while (element.getSchemaType() == null && element.isRef()) {
        /*
             * This code assumes that all schemas are in the collection.
             */
        XmlSchemaElement nextElement = element.getRef().getTarget();
        assert nextElement != null;
        element = nextElement;
    }
    if (element.getSchemaType() == null) {
        unsupportedConstruct("ELEMENT_HAS_NO_TYPE", originalElement.getName(), containingType.getQName(), containingType);
    }
    return element.getSchemaType();
}
Also used : Message(org.apache.cxf.common.i18n.Message) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) UnsupportedConstruct(org.apache.cxf.javascript.UnsupportedConstruct) 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