Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.SchemaParticle


    private void addSchemaType(QName typeQName, SchemaType schemaType, boolean anonymous, Map qnameMap) {
        SchemaTypeKey typeKey = new SchemaTypeKey(typeQName, false, schemaType.isSimpleType(), anonymous, null);
        qnameMap.put(typeKey, schemaType);
//        new Exception("Adding: " + typeKey.getqName().getLocalPart()).printStackTrace();
        //TODO xmlbeans recommends using summary info from getElementProperties and getAttributeProperties instead of traversing the content model by hand.
        SchemaParticle schemaParticle = schemaType.getContentModel();
        if (schemaParticle != null) {
            addSchemaParticle(schemaParticle, typeKey, qnameMap);
        }
    }
View Full Code Here


            }
        } else {
            try {
                SchemaParticle[] children = schemaParticle.getParticleChildren();
                for (int i = 0; i < children.length; i++) {
                    SchemaParticle child = children[i];
                    addSchemaParticle(child, key, qnameMap);
                }
            } catch (NullPointerException e) {
                //ignore xmlbeans bug
            }
View Full Code Here

            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);

            Set expectedInParams = new HashSet();

            // schemaType should be complex using xsd:sequence compositor
            SchemaParticle parametersType = operationType.getContentModel();
            //parametersType can be null if the element has empty content such as
//            <element name="getMarketSummary">
//             <complexType>
//              <sequence/>
//             </complexType>
//            </element>

            if (parametersType != null) {
                if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
                    expectedInParams.add(parametersType.getName().getLocalPart());
                } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
                    SchemaParticle[] parameters = parametersType.getParticleChildren();
                    for (int i = 0; i < parameters.length; i++) {
                        expectedInParams.add(parameters[i].getName().getLocalPart());
                    }
                }
            }
            if (!inParamNames.equals(expectedInParams)) {
                throw new DeploymentException("Not all wrapper children were mapped for operation name" + operationName);
            }
        } else {
            //check that all input message parts are mapped
            if (!inParamNames.equals(input.getParts().keySet())) {
                throw new DeploymentException("Not all input message parts were mapped for operation name" + operationName);
            }
        }

        Class[] paramTypes = new Class[parameterDescriptions.length];
        for (int i = 0; i < parameterDescriptions.length; i++) {
            ParameterDesc parameterDescription = parameterDescriptions[i];
            if (parameterDescription == null) {
                throw new DeploymentException("There is no mapping for parameter number " + i + " for operation " + operationName);
            }
            operationDesc.addParameter(parameterDescription);
            paramTypes[i] = parameterDescription.getJavaType();
        }

        String methodName = methodMapping.getJavaMethodName().getStringValue().trim();
        Method method = null;
        try {
            method = serviceEndpointInterface.getMethod(methodName, paramTypes);
        } catch (NoSuchMethodException e) {
            String args = "(";
            for (int i = 0; i < paramTypes.length; i++) {
                args += paramTypes[i].getName();
                if (i < paramTypes.length - 1) {
                    args += ",";
                }
            }
            args += ")";

            throw new DeploymentException("Mapping references non-existent method in service-endpoint: " + methodName + args);
        }

        operationDesc.setMethod(method);

        // MAP RETURN TYPE
        operationDesc.setMep(operation.getStyle());
        if (methodMapping.isSetWsdlReturnValueMapping()) {
            mapReturnType();
        } else if (operation.getStyle() == OperationType.REQUEST_RESPONSE) {
            //TODO WARNING THIS APPEARS TO SUBVERT THE COMMENT IN j2ee_jaxrpc_mapping_1_1.xsd IN service-endpoint-method-mappingType:
            //The wsdl-return-value-mapping is not specified for one-way operations.
            operationDesc.setReturnQName(null);             //??
            operationDesc.setReturnType(XMLType.AXIS_VOID);
            operationDesc.setReturnClass(void.class);
        }

        if (null != output && wrappedStyle) {
            Part inputPart = getWrappedPart(output);
            QName name = inputPart.getElementName();
            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);

            Set expectedOutParams = new HashSet();

            // schemaType should be complex using xsd:sequence compositor
            SchemaParticle parametersType = operationType.getContentModel();
            //again, no output can give null parametersType
            if (parametersType != null) {
                if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
                    expectedOutParams.add(parametersType.getName().getLocalPart());
                } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
                    SchemaParticle[] parameters = parametersType.getParticleChildren();
                    for (int i = 0; i < parameters.length; i++) {
                        expectedOutParams.add(parameters[i].getName().getLocalPart());
                    }
                }
            }
View Full Code Here

                throw new DeploymentException("output message part " + wsdlMessagePartName + " has both an INOUT or OUT mapping and a return value mapping for operation " + operationName);
            }

            if (wrappedStyle) {
                Part outPart = getWrappedPart(output);
                SchemaParticle returnParticle = getWrapperChild(outPart, wsdlMessagePartName);
                //TODO this makes little sense but may be correct, see comments in axis Parameter class
                //the part name qname is really odd.
                returnQName = new QName("", returnParticle.getName().getLocalPart());
                returnType = returnParticle.getType().getName();
            } else if (rpcStyle) {
                Part part = output.getPart(wsdlMessagePartName);
                if (part == null) {
                    throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
                }
View Full Code Here

        QName paramQName;
        QName paramTypeQName;

        Part part = null;
        SchemaParticle inParameter = null;
        if (isInParam) {
            if (!wsdlMessageQName.equals(input.getQName())) {
                throw new DeploymentException("QName of input message: " + input.getQName() +
                        " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
            }
            if (wrappedStyle) {
                Part inPart = getWrappedPart(input);
                // the local name of the global element refered by the part is equal to the operation name
                QName name = inPart.getElementName();
                if (false == name.getLocalPart().equals(operationName)) {
                    throw new DeploymentException("message " + input.getQName() + " refers to a global element named " +
                            name.getLocalPart() + ", which is not equal to the operation name " + operationName);
                }
                inParameter = getWrapperChild(inPart, wsdlMessagePartName);
                //TODO this makes little sense but may be correct, see comments in axis Parameter class
                //the part name qname is really odd.
                paramQName = new QName("", inParameter.getName().getLocalPart());
                paramTypeQName = inParameter.getType().getName();
            } else if (rpcStyle) {
                part = input.getPart(wsdlMessagePartName);
                if (part == null) {
                    throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in input message for operation " + operationName);
                }
                //TODO this makes little sense but may be correct, see comments in axis Parameter class
                //the part name qname is really odd.
                paramQName = new QName("", part.getName());
                paramTypeQName = part.getTypeName();
            } else {
                part = input.getPart(wsdlMessagePartName);
                if (part == null) {
                    throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in input message for operation " + operationName);
                }
                paramQName = getPartName(part);
                paramTypeQName = paramQName;
            }
            inParamNames.add(wsdlMessagePartName);
            if (isOutParam) {
                if (wrappedStyle) {
                    Part outPart = getWrappedPart(output);
                    SchemaParticle outParameter = getWrapperChild(outPart, wsdlMessagePartName);
                    if (inParameter.getType() != outParameter.getType()) {
                        throw new DeploymentException("The wrapper children " + wsdlMessagePartName +
                                " do not have the same type for operation " + operationName);
                    }
                } else if (rpcStyle) {
                    //inout, check that part of same name and type is in output message
                    Part outPart = output.getPart(wsdlMessagePartName);
                    if (outPart == null) {
                        throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for INOUT parameter of operation " + operationName);
                    }
                    // TODO this cannot happen.
                    if (!part.getName().equals(outPart.getName())) {
                        throw new DeploymentException("Mismatched input part name: " + part.getName() + " and output part name: " + outPart.getName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
                    }
                    if (!(part.getElementName() == null ? outPart.getElementName() == null : part.getElementName().equals(outPart.getElementName()))) {
                        throw new DeploymentException("Mismatched input part element name: " + part.getElementName() + " and output part element name: " + outPart.getElementName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
                    }
                    if (!(part.getTypeName() == null ? outPart.getTypeName() == null : part.getTypeName().equals(outPart.getTypeName()))) {
                        throw new DeploymentException("Mismatched input part type name: " + part.getTypeName() + " and output part type name: " + outPart.getTypeName() + " for INOUT parameter for wsdlMessagePartName " + wsdlMessagePartName + " for operation " + operationName);
                    }
                } else {
                    part = output.getPart(wsdlMessagePartName);
                    if (part == null) {
                        throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
                    }
                    paramQName = getPartName(part);
                    paramTypeQName = paramQName;
                }
                outParamNames.add(wsdlMessagePartName);
            }
        } else if (isOutParam) {
            if (!wsdlMessageQName.equals(output.getQName())) {
                throw new DeploymentException("QName of output message: " + output.getQName() +
                        " does not match mapping message QName: " + wsdlMessageQName + " for operation " + operationName);
            }
            if (wrappedStyle) {
                Part outPart = getWrappedPart(output);
                SchemaParticle outParameter = getWrapperChild(outPart, wsdlMessagePartName);
                //TODO this makes little sense but may be correct, see comments in axis Parameter class
                //the part name qname is really odd.
                paramQName = new QName("", outParameter.getName().getLocalPart());
                paramTypeQName = outParameter.getType().getName();
            } else if (rpcStyle) {
                part = output.getPart(wsdlMessagePartName);
                if (part == null) {
                    throw new DeploymentException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in output message for operation " + operationName);
                }
View Full Code Here

        if (null == operationType) {
            throw new DeploymentException("No global element named " + name + " for operation " + operationName);
        }

        // schemaType should be complex using xsd:sequence compositor
        SchemaParticle parametersType = operationType.getContentModel();
        if (SchemaParticle.ELEMENT == parametersType.getParticleType()) {
            if (parametersType.getName().getLocalPart().equals(wsdlMessagePartName)) {
                return parametersType;
            }
            throw new DeploymentException("Global element named " + name +
                    " does not define a child element named " + wsdlMessagePartName +
                    " required by the operation " + operationName);
        } else if (SchemaParticle.SEQUENCE == parametersType.getParticleType()) {
            SchemaParticle[] parameters = parametersType.getParticleChildren();
            for (int i = 0; i < parameters.length; i++) {
                SchemaParticle parameter = parameters[i];
                QName element = parameter.getName();
                if (element.getLocalPart().equals(wsdlMessagePartName)) {
                    return parameter;
                }
            }
            throw new DeploymentException("Global element named " + name +
View Full Code Here

    public QName getDocumentElementName()
    {
        if (_isDocumentType)
        {
            SchemaParticle sp = getContentModel();
            if (sp != null)
                return sp.getName();
        }

        return null;
    }
View Full Code Here

    {
        // To compute the element setter model, we need to compute the
        // delimiting elements for each element.

        SchemaProperty[] eltProps = getElementProperties();
        SchemaParticle contentModel = getContentModel();
        Map state = new HashMap();
        QNameSet allContents = computeAllContainedElements(contentModel, state);

        for (int i = 0; i < eltProps.length; i++)
        {
View Full Code Here

     *  the returned QNameSet will not contain the qname of 'someElement'.
     * @return the constructed QNameSet
     */
    public QNameSet qnameSetForWildcardElements()
    {
        SchemaParticle model = this.getContentModel();
        QNameSetBuilder wildcardSet = new QNameSetBuilder();
        computeWildcardSet(model, wildcardSet);

        QNameSetBuilder qnsb = new QNameSetBuilder( wildcardSet );
        SchemaProperty[] props = this.getElementProperties();
View Full Code Here

            result.addAll(cws);
            return;
        }
        for (int i = 0; i < model.countOfParticleChild(); i++)
        {
            SchemaParticle child = model.getParticleChild(i);
            computeWildcardSet(child, result);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.SchemaParticle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.