Search in sources :

Example 41 with XmlSchemaType

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

the class ServiceJavascriptBuilder method createResponseDeserializer.

// This ignores 'wrapped', because it assumes one part that we can use one way or
// the other. For simple cases, this is certainly OK.
private void createResponseDeserializer(MessageInfo outputMessage) {
    List<MessagePartInfo> parts = outputMessage.getMessageParts();
    if (parts.size() != 1) {
        unsupportedConstruct("MULTIPLE_OUTPUTS", outputMessage.getName().toString());
    }
    List<ParticleInfo> elements = new ArrayList<>();
    String functionName = outputDeserializerFunctionName(outputMessage);
    code.append("function ").append(functionName).append("(cxfjsutils, partElement) {\n");
    getElementsForParts(outputMessage, elements);
    ParticleInfo element = elements.get(0);
    if (isRPC) {
        utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
        utils.appendLine("partElement = cxfjsutils.getFirstElementChild(partElement);");
        utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
    }
    XmlSchemaType type = element.getType();
    if (!element.isEmpty()) {
        if (type instanceof XmlSchemaComplexType) {
            String typeObjectName = nameManager.getJavascriptName(element.getControllingName());
            utils.appendLine("var returnObject = " + typeObjectName + "_deserialize (cxfjsutils, partElement);\n");
            utils.appendLine("return returnObject;");
        } else if (type instanceof XmlSchemaSimpleType) {
            XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type;
            utils.appendLine("var returnText = cxfjsutils.getNodeText(partElement);");
            utils.appendLine("var returnObject = " + utils.javascriptParseExpression(simpleType, "returnText") + ";");
            utils.appendLine("return returnObject;");
        } else if (type != null) {
            utils.appendLine("// Unsupported construct " + type.getClass());
        } else {
            utils.appendLine("// No type for element " + element.getXmlName());
        }
    }
    code.append("}\n");
}
Also used : XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) ParticleInfo(org.apache.cxf.javascript.ParticleInfo) ArrayList(java.util.ArrayList) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 42 with XmlSchemaType

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

the class WSDLRefValidator method validatePartType.

private boolean validatePartType(String namespace, String name, boolean isElement) {
    boolean partvalid = false;
    if (namespace.equals(WSDLConstants.NS_SCHEMA_XSD)) {
        if (isElement) {
            XmlSchemaElement schemaEle = schemaCollection.getElementByQName(new QName(WSDLConstants.NS_SCHEMA_XSD, name));
            partvalid = schemaEle != null ? true : false;
        } else {
            if ("anyType".equals(name)) {
                return true;
            }
            XmlSchemaType schemaType = schemaCollection.getTypeByQName(new QName(WSDLConstants.NS_SCHEMA_XSD, name));
            partvalid = schemaType != null ? true : false;
        }
    } else {
        if (isElement) {
            if (schemaCollection.getElementByQName(new QName(namespace, name)) != null) {
                partvalid = true;
            }
        } else {
            if (schemaCollection.getTypeByQName(new QName(namespace, name)) != null) {
                partvalid = true;
            }
        }
    }
    return partvalid;
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 43 with XmlSchemaType

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

the class ConstVisitor method visit.

public void visit(AST constNode) {
    // <const_dcl> ::= "const" <const_type> <identifier> "=" <const_exp>
    // <const_type> ::= <integer_type>
    // | <char_type>
    // | <wide_char_type>
    // | <boolean_type>
    // | <floating_pt_type>
    // | <string_type>
    // | <wide_string_type>
    // | <fixed_pt_const_type>
    // | <scoped_name>
    // | <octet_type>
    AST constTypeNode = constNode.getFirstChild();
    AST constNameNode = TypesUtils.getCorbaTypeNameNode(constTypeNode);
    AST constValueNode = constNameNode.getNextSibling();
    // build value string
    StringBuilder constValue = new StringBuilder();
    if (constValueNode.toString() != null) {
        constValue.append(constValueNode.toString());
    }
    constValueNode = constValueNode.getFirstChild();
    if (constValue.length() == 1) {
        // might be a control char
        byte ch = (byte) constValue.charAt(0);
        if (ch >= 0 && ch <= 31) {
            // ascii code between 0 and 31 is invisible control code
            constValue.deleteCharAt(0);
            constValue.append('\\').append(Integer.toOctalString(ch));
        }
    }
    while (constValueNode != null) {
        constValue.append(constValueNode.toString());
        constValueNode = constValueNode.getFirstChild();
    }
    QName constQName = new QName(typeMap.getTargetNamespace(), new Scope(getScope(), constNameNode).toString());
    Visitor visitor = null;
    if (PrimitiveTypesVisitor.accept(constTypeNode)) {
        visitor = new PrimitiveTypesVisitor(getScope(), definition, schema, schemas);
    } else if (StringVisitor.accept(constTypeNode)) {
        // string_type_spec
        // wstring_type_spec
        visitor = new StringVisitor(getScope(), definition, schema, wsdlVisitor, constTypeNode);
    } else if (FixedPtConstVisitor.accept(constTypeNode)) {
        visitor = new FixedPtConstVisitor(getScope(), definition, schema, schemas);
    } else if (ScopedNameVisitor.accept(getScope(), definition, schema, constTypeNode, wsdlVisitor)) {
        visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
    }
    if (visitor == null) {
        throw new RuntimeException("can't resolve type for const " + constNameNode.getText());
    }
    visitor.visit(constTypeNode);
    XmlSchemaType constSchemaType = visitor.getSchemaType();
    CorbaTypeImpl constCorbaType = visitor.getCorbaType();
    // corba:const
    Const corbaConst = new Const();
    corbaConst.setQName(constQName);
    corbaConst.setValue(constValue.toString());
    corbaConst.setType(constSchemaType.getQName());
    corbaConst.setIdltype(constCorbaType.getQName());
    typeMap.getStructOrExceptionOrUnion().add(corbaConst);
}
Also used : AST(antlr.collections.AST) QName(javax.xml.namespace.QName) CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl) Const(org.apache.cxf.binding.corba.wsdl.Const) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 44 with XmlSchemaType

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

the class DeclaratorVisitor method visitNewTypes.

private void visitNewTypes(Scope newScope) {
    CorbaType nextCorbaType = null;
    CorbaType oldCorbaType = getCorbaType();
    QName newQname = new QName(getCorbaType().getQName().getNamespaceURI(), newScope.toString());
    if (oldCorbaType instanceof Alias) {
        // Alias
        // 
        Alias oldAlias = (Alias) oldCorbaType;
        Alias alias = new Alias();
        alias.setQName(newQname);
        alias.setBasetype(oldAlias.getBasetype());
        alias.setType(oldAlias.getType());
        alias.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = alias;
    } else if (oldCorbaType instanceof Sequence) {
        // Sequence
        // 
        XmlSchemaType nextSchemaType = duplicateXmlSchemaComplexType(newScope);
        Sequence oldSequence = (Sequence) oldCorbaType;
        Sequence newSequence = new Sequence();
        newSequence.setQName(newQname);
        newSequence.setType(nextSchemaType.getQName());
        newSequence.setElemtype(oldSequence.getElemtype());
        newSequence.setElemname(oldSequence.getElemname());
        newSequence.setBound(oldSequence.getBound());
        newSequence.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = newSequence;
    } else if (oldCorbaType instanceof Fixed) {
        // Fixed
        // 
        // nextSchemaType =
        duplicateXmlSchemaSimpleType(newScope);
        Fixed oldFixed = (Fixed) getCorbaType();
        Fixed newFixed = new Fixed();
        newFixed.setQName(newQname);
        newFixed.setDigits(oldFixed.getDigits());
        newFixed.setScale(oldFixed.getScale());
        newFixed.setType(oldFixed.getType());
        newFixed.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = newFixed;
    } else {
        System.err.println("[DeclaratorVisitor: Unexpected CORBA type error!]");
        // NOPMD
        System.exit(1);
    }
    if (nextCorbaType != null) {
        typeMap.getStructOrExceptionOrUnion().add(nextCorbaType);
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 45 with XmlSchemaType

use of org.apache.ws.commons.schema.XmlSchemaType in project tdi-studio-se by Talend.

the class ComponentBuilder method collectAllXmlSchemaType.

/**
     * DOC gcui Comment method "collectAllXmlSchemaType".
     */
private void collectAllXmlSchemaType() {
    for (int i = 0; i < wsdlTypes.size(); i++) {
        XmlSchema xmlSchema = (wsdlTypes.elementAt(i));
        if (xmlSchema == null) {
            continue;
        }
        XmlSchemaObjectTable xmlSchemaObjectTable = xmlSchema.getSchemaTypes();
        Iterator typesItr = xmlSchemaObjectTable.getValues();
        while (typesItr.hasNext()) {
            XmlSchemaType xmlSchemaType = (XmlSchemaType) typesItr.next();
            allXmlSchemaType.add(xmlSchemaType);
        }
    }
}
Also used : XmlSchemaObjectTable(org.apache.ws.commons.schema.XmlSchemaObjectTable) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Iterator(java.util.Iterator) 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