org.apache.ws.commons.schema.XmlSchemaElement Java Examples

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Xsd2CobolTypesModelBuilder.java    From legstar-core2 with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Contribute array-related properties.
 * <p/>
 * If this is a array depending on, there must me a corresponding ODO Object
 * that we enrich with the array dimensions as the numeric range.
 * 
 * @param xsdElement the xsd element marked as an array
 * @param cobolAnnotations the xsd element COBOL annotations
 * @param props the corresponding set of properties
 */
@SuppressWarnings("unchecked")
private void addArrayProps(XmlSchemaElement xsdElement,
        CobolAnnotations cobolAnnotations, Map < String, Object > props) {
    props.put(MIN_OCCURS_PROP_NAME, xsdElement.getMinOccurs());
    props.put(MAX_OCCURS_PROP_NAME, xsdElement.getMaxOccurs());
    String dependingOn = cobolAnnotations.getDependingOn();
    if (dependingOn != null) {
        Map < String, Object > depProps = (Map < String, Object >) odoObjects
                .get(dependingOn);
        depProps.put(MIN_INCLUSIVE_PROP_NAME,
                Long.toString(xsdElement.getMinOccurs()));
        depProps.put(MAX_INCLUSIVE_PROP_NAME,
                Long.toString(xsdElement.getMaxOccurs()));

        props.put(DEPENDING_ON_PROP_NAME, odoObjectNames.get(dependingOn));
    }
}
 
Example #2
Source File: XmlSchemaExtractor.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private void handleElement(XmlSchemaElement target, XmlSchemaElement source) throws ParserException {
    // copy constraints as is
    target.getConstraints().addAll(source.getConstraints());

    // handle substitution group if present
    QName name = source.getSubstitutionGroup();
    // check if target schemas don't have the substitution element
    if (name != null && targetSchemas.getElementByQName(name) == null) {
        final XmlSchemaElement substitute = sourceSchemas.getElementByQName(name);
        if (substitute == null) {
            throw new ParserException("Missing element in source schemas: " + name);
        }

        // create a copy in target schemas
        createXmlSchemaObjectBase(substitute);
    }

    handleTypeNameAndType(source.getSchemaTypeName(), source.getSchemaType(),
        target::setSchemaTypeName, target::setType);
}
 
Example #3
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean getElementQualification(XmlSchemaElement element, String uri) {
    QName schemaName = element.getQName();
    if (element.isRef()) {
        schemaName = element.getRef().getTargetQName();
    }

    if (schemaName.getNamespaceURI().isEmpty()) {
        schemaName = new QName(uri, schemaName.getLocalPart());
    }
    boolean qualified = false;
    if (element.getForm() == XmlSchemaForm.QUALIFIED) {
        qualified = true;
    } else {
        qualified = WSDLUtils.isElementFormQualified(xmlSchemaList, schemaName);
    }
    return qualified;
}
 
Example #4
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void addType(QName typeQName, XmlSchemaType type) {
    // skip built in xml schema types
    if (XML_SCHEMA_NS.equals(typeQName.getNamespaceURI())) {
        return;
    }

    XmlTypeInfo typeInfo = createXmlTypeInfo(typeQName, type);
    xmlTypes.put(typeQName, typeInfo);

    if (type instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;

        // process elements nested inside of this element
        List<XmlSchemaElement> elements = getNestedElements(complexType);
        for (XmlSchemaElement element : elements) {
            addNestedElement(element, typeInfo);
        }
    }
}
 
Example #5
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
    SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(),
                                      getQualifyWrapperSchema());
    XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart());
    if (e != null) {
        mpi.setXmlSchema(e);
        return;
    }
    XmlSchema schema = si.getSchema();
    si.setElement(null); //cached element is now invalid

    XmlSchemaElement el = new XmlSchemaElement(schema, true);
    el.setName(mpi.getElementQName().getLocalPart());
    el.setNillable(true);

    XmlSchemaType tp = (XmlSchemaType)mpi.getXmlSchema();
    if (tp == null) {
        throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG,
                                                           mpi.getName(),
                                                           mpi.getMessageInfo().getName()));
    }
    el.setSchemaTypeName(tp.getQName());
    mpi.setXmlSchema(el);
}
 
Example #6
Source File: MapType.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void writeSchema(XmlSchema root) {
    XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true);
    complex.setName(getSchemaType().getLocalPart());
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    complex.setParticle(sequence);

    AegisType kType = getKeyType();
    AegisType vType = getValueType();

    XmlSchemaElement element = new XmlSchemaElement(root, false);
    sequence.getItems().add(element);
    element.setName(getEntryName().getLocalPart());
    element.setMinOccurs(0);
    element.setMaxOccurs(Long.MAX_VALUE);

    XmlSchemaComplexType evType = new XmlSchemaComplexType(root, false);
    element.setType(evType);

    XmlSchemaSequence evSequence = new XmlSchemaSequence();
    evType.setParticle(evSequence);

    createElement(root, evSequence, getKeyName(), kType, false);
    createElement(root, evSequence, getValueName(), vType, true);
}
 
Example #7
Source File: WSDLParameter.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean isObjectReference(SchemaCollection schemaList, QName name) {
    for (XmlSchema schema : schemaList.getXmlSchemas()) {
        XmlSchemaElement element = schema.getElementByName(name);
        if (element != null) {
            XmlSchemaAnnotation annotation = element.getAnnotation();
            if (annotation != null) {
                List<XmlSchemaAnnotationItem> annotationColl = annotation.getItems();
                for (XmlSchemaAnnotationItem item : annotationColl) {
                    if (item instanceof XmlSchemaAppInfo) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
Example #8
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected XmlSchemaType lookUpType(Part part) {
    XmlSchemaType schemaType = null;
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getElementName() != null) {
            XmlSchemaElement schemaElement = xmlSchema.getElementByName(part.getElementName());
            if (schemaElement != null) {
                schemaType = schemaElement.getSchemaType();
            }
        } else {
            if (part.getTypeName() != null) {
                schemaType = xmlSchema.getTypeByName(part.getTypeName());
            }
        }
        if (schemaType != null) {
            return schemaType;
        }
    }

    return schemaType;
}
 
Example #9
Source File: Xsd2CobolTypesModelBuilder.java    From legstar-core2 with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Process each element in the input Schema.
 * <p/>
 * 
 * @param xmlSchema the XML schema with COBOL annotations
 * @return a map of root elements in the XML schema, each one mapped to its
 *         composite types constituents
 * @throws Xsd2ConverterException if parsing the XML schema fails
 */
public Map < String, RootCompositeType > build(XmlSchema xmlSchema)
        throws Xsd2ConverterException {

    log.debug("visit XML Schema started");
    Map < String, RootCompositeType > rootComplexTypes = new LinkedHashMap < String, RootCompositeType >();

    for (Entry < QName, XmlSchemaElement > entry : xmlSchema.getElements()
            .entrySet()) {
        if (entry.getValue().getSchemaType() instanceof XmlSchemaComplexType) {
            CobolAnnotations cobolAnnotations = new CobolAnnotations(
                    entry.getValue());
            XmlSchemaComplexType xsdComplexType = (XmlSchemaComplexType) entry
                    .getValue().getSchemaType();
            RootCompositeType compositeTypes = new RootCompositeType(
                    cobolAnnotations.getCobolName());
            String complexTypeName = getComplexTypeName(xsdComplexType);
            rootComplexTypes.put(complexTypeName, compositeTypes);
            visit(xsdComplexType, compositeTypes, complexTypeName);
        }
    }

    log.debug("visit XML Schema ended");
    return rootComplexTypes;
}
 
Example #10
Source File: WSDLParameter.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean isWrappableSequence(XmlSchemaComplexType type) {
    if (type.getParticle() instanceof XmlSchemaSequence) {
        XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
        List<XmlSchemaSequenceMember> items = seq.getItems();

        for (XmlSchemaSequenceMember member : items) {
            if (!(member instanceof XmlSchemaElement)) {
                return false;
            }
        }

        return true;
    } else if (type.getParticle() == null) {
        return true;
    }
    return false;
}
 
Example #11
Source File: WSDLParameter.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static XmlSchemaElement findElement(XmlSchema xmlSchema, QName elName) {
    XmlSchemaElement schemaElement = null;

    schemaElement = xmlSchema.getElementByName(elName);
    if (schemaElement == null) {
        String prefix = definition.getPrefix(elName.getNamespaceURI());
        QName name = new QName(elName.getNamespaceURI(), prefix + ":" + elName.getLocalPart(), prefix);
        schemaElement = xmlSchema.getElementByName(name);
    }
    if (schemaElement != null) {
        return schemaElement;
    }
    for (XmlSchemaExternal ext : xmlSchema.getExternals()) {
        if (!(ext instanceof XmlSchemaImport)) {
            schemaElement = findElement(ext.getSchema(), elName);
            if (schemaElement != null) {
                return schemaElement;
            }
        }
    }
    return schemaElement;
}
 
Example #12
Source File: XsdToNeutralSchemaRepo.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
void loadSchema(XmlSchema schema) {
    XmlSchemaObjectCollection schemaItems = schema.getItems();

    // Iterate XML Schema items
    for (int i = 0; i < schemaItems.getCount(); i++) {
        XmlSchemaObject schemaObject = schemaItems.getItem(i);

        NeutralSchema neutralSchema;
        if (schemaObject instanceof XmlSchemaType) {
            neutralSchema = parse((XmlSchemaType) schemaObject, schema);
        } else if (schemaObject instanceof XmlSchemaElement) {
            neutralSchema = parseElement((XmlSchemaElement) schemaObject, schema);
        } else if (schemaObject instanceof XmlSchemaInclude) {
            continue; // nothing to do for includes
        } else {
            throw new RuntimeException("Unhandled XmlSchemaObject: " + schemaObject.getClass().getCanonicalName());
        }
        schemas.put(neutralSchema.getType(), neutralSchema);
        partialSchemas.clear();
    }
}
 
Example #13
Source File: ObjectReferenceVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean isReferenceSchemaTypeDefined(QName objectReferenceName,
                                             XmlSchema refSchema) {
    List<XmlSchemaObject> schemaObjects = refSchema.getItems();

    for (XmlSchemaObject schemaObj : schemaObjects) {
        if (schemaObj instanceof XmlSchemaElement) {
            XmlSchemaElement el = (XmlSchemaElement)schemaObj;

            if (el.getName().equals(objectReferenceName.getLocalPart())) {
                return true;
            }
        }
    }

    return false;
}
 
Example #14
Source File: JAXBSchemaInitializer.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addExceptionMessage(Class<?> cls, XmlSchema schema, XmlSchemaSequence seq) {
    try {
        //a subclass could mark the message method as transient
        Method m = cls.getMethod("getMessage");
        if (!m.isAnnotationPresent(XmlTransient.class)
            && m.getDeclaringClass().equals(Throwable.class)) {
            JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class);
            XmlSchemaElement exEle = new XmlSchemaElement(schema, false);
            exEle.setName("message");
            exEle.setSchemaTypeName(getTypeName(beanInfo));
            exEle.setMinOccurs(0);
            seq.getItems().add(exEle);
        }
    } catch (Exception e) {
        //ignore, just won't have the message element
    }
}
 
Example #15
Source File: JaxWsServiceFactoryBeanTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testDocLiteralPartWithType() throws Exception {
    ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setServiceClass(NoBodyPartsImpl.class);
    Service service = serviceFactory.create();
    ServiceInfo serviceInfo =
        service.getServiceInfos().get(0);
    QName qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl",
                            "operation1");
    MessageInfo mi = serviceInfo.getMessage(qname);
    qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl",
        "mimeAttachment");
    MessagePartInfo mpi = mi.getMessagePart(qname);
    QName elementQName = mpi.getElementQName();
    XmlSchemaElement element =
        serviceInfo.getXmlSchemaCollection().getElementByQName(elementQName);
    assertNotNull(element);
}
 
Example #16
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Recursively parse through an XmlSchemaPatricle to the elements
 * collecting all DidRefSources
 */
private XmlSchemaElement parseParticleForIdentityType(XmlSchemaParticle particle) {
    XmlSchemaElement identityType = null;
    if (particle != null) {
        if (particle instanceof XmlSchemaElement) {
            XmlSchemaElement element = (XmlSchemaElement) particle;
            String elementName = element.getSchemaTypeName().getLocalPart();
            if (elementName.contains(IDENTITY_TYPE)) {
                identityType = element;
            }
        } else if (particle instanceof XmlSchemaSequence) {
            XmlSchemaSequence schemaSequence = (XmlSchemaSequence) particle;
            for (int i = 0; i < schemaSequence.getItems().getCount(); i++) {
                XmlSchemaObject item = schemaSequence.getItems().getItem(i);
                if (item instanceof XmlSchemaParticle) {
                    identityType = parseParticleForIdentityType((XmlSchemaParticle) item);
                }
            }
        }
    }
    return identityType;
}
 
Example #17
Source File: XmlSchemaUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * due to a bug, feature, or just plain oddity of JAXB, it isn't good enough
 * to just check the form of an element and of its schema. If schema 'a'
 * (default unqualified) has a complex type with an element with a ref= to
 * schema (b) (default unqualified), JAXB seems to expect to see a
 * qualifier, anyway. <br/> So, if the element is local to a complex type,
 * all we care about is the default element form of the schema and the local
 * form of the element. <br/> If, on the other hand, the element is global,
 * we might need to compare namespaces. <br/>
 *
 * @param element the element.
 * @param global if this element is a global element (complex type ref= to
 *                it, or in a part)
 * @param localSchema the schema of the complex type containing the
 *                reference, only used for the 'odd case'.
 * @param elementSchema the schema for the element.
 * @return if the element needs to be qualified.
 */
public static boolean isElementQualified(XmlSchemaElement element,
                                         boolean global,
                                         XmlSchema localSchema,
                                         XmlSchema elementSchema) {
    QName qn = getElementQualifiedName(element, localSchema);
    if (qn == null) {
        throw new RuntimeException("isElementQualified on anonymous element.");
    }
    if (element.isRef()) {
        throw new RuntimeException("isElementQualified on the 'from' side of ref=.");
    }


    if (global) {
        return isElementNameQualified(element, elementSchema)
            || (localSchema != null
                && !(qn.getNamespaceURI().equals(localSchema.getTargetNamespace())));
    }
    return isElementNameQualified(element, elementSchema);
}
 
Example #18
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Message generateMessage(XmlSchemaElement element, String name) {
    Part part = definition.createPart();
    part.setName(PART_NAME);
    part.setElementName(element.getQName());

    Message result = definition.createMessage();

    QName qName = new QName(definition.getTargetNamespace(), name);
    if (definition.getMessage(qName) != null) {
        String newName = getScope().toString() + "." + name;
        qName = new QName(definition.getTargetNamespace(), newName);
    }


    result.setQName(qName);
    result.addPart(part);
    result.setUndefined(false);
    definition.addMessage(result);

    return result;
}
 
Example #19
Source File: ExceptionVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private XmlSchemaElement createElementType(AST memberNode, XmlSchemaType stype,
                                           Scope fqName) {
    // xmlschema:member
    XmlSchemaElement member = new XmlSchemaElement(schema, false);
    String memberName = memberNode.toString();
    member.setName(memberName);
    if (stype != null) {
        member.setSchemaType(stype);
        member.setSchemaTypeName(stype.getQName());
        if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            member.setNillable(true);
        }
    } else {
        wsdlVisitor.getDeferredActions().
            add(fqName, new ExceptionDeferredAction(member));
    }
    return member;
}
 
Example #20
Source File: StructVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private XmlSchemaElement createXmlSchemaElement(AST memberNode,
                                                XmlSchemaType schemaType,
                                                Scope fqName) {
    // xmlschema:member
    XmlSchemaElement member = new XmlSchemaElement(schema, false);
    String memberName = memberNode.toString();
    member.setName(memberName);
    member.setSchemaType(schemaType);
    if (schemaType != null) {
        member.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            member.setNillable(true);
        }
    } else {
        wsdlVisitor.getDeferredActions().
            add(fqName, new StructDeferredAction(member));
    }
    return member;
}
 
Example #21
Source File: WSDLParameter.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static XmlSchemaElement getSchemaObject(WSDLToCorbaBinding wsdlToCorbaBinding, QName typeName) {

        SchemaCollection schemaList = wsdlToCorbaBinding.getHelper().getXMLSchemaList();
        for (XmlSchema s : schemaList.getXmlSchemas()) {
            XmlSchemaElement e = s.getElementByName(typeName);
            if (e != null) {
                return e;
            }
        }
        return null;
    }
 
Example #22
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public CorbaType convertSchemaToCorbaType(XmlSchemaType stype,
                                              QName defaultName,
                                              XmlSchemaType parent,
                                              XmlSchemaAnnotation annotation,
                                              boolean anonymous)
    throws Exception {
    CorbaType corbaTypeImpl = null;
    if (!isAddressingNamespace(stype.getQName())) {
        // need to determine if its a primitive type.
        if (stype instanceof XmlSchemaComplexType) {
            corbaTypeImpl = processComplexType((XmlSchemaComplexType)stype,
                                                          defaultName, annotation, anonymous);
        } else if (stype instanceof XmlSchemaSimpleType) {
            corbaTypeImpl = processSimpleType((XmlSchemaSimpleType)stype,
                                              defaultName, anonymous);
        }  else if (xmlSchemaList.getElementByQName(stype.getQName()) != null) {
            XmlSchemaElement el = xmlSchemaList.getElementByQName(stype.getQName());
            //REVISIT, passing ns uri because of a bug in XmlSchema (Bug: WSCOMMONS-69)
            corbaTypeImpl = processElementType(el,
                                               defaultName,
                                               stype.getQName().getNamespaceURI());
        } else {
            throw new Exception("Couldn't convert schema " + stype.getQName() + " to corba type");
        }
    }

    if (corbaTypeImpl != null && !isDuplicate(corbaTypeImpl)) {
        typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
    }

    return corbaTypeImpl;
}
 
Example #23
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * Extract refConfig for a refType
 */
private DidRefConfig extractRefConfig(XmlSchemaComplexType refType) {
    // get the identityType out of the refType
    DidRefConfig refConfig = null;

    // check that this refConfig is configures to go through DID Resolver
    DidRefSource refSource = getRefSource(refType);

    if (refSource != null) {
        // find the identity type element
        XmlSchemaElement identityTypeElement = null;

        identityTypeElement = parseParticleForIdentityType(extractParticle(refType));

        if (identityTypeElement != null) {
            XmlSchemaComplexType identityType = null;
            identityType = complexTypes.get(identityTypeElement.getSchemaTypeName().getLocalPart());
            String baseXPath = identityTypeElement.getName() + ".";

            // need this to recursively extract refConfigs
            refConfig = new DidRefConfig();
            refConfig.setEntityType(refSource.getEntityType());

            // parse the reference type
            parseParticleForRefConfig(extractParticle(identityType), refConfig, baseXPath, false);

        } else {
            LOG.error("Failed to extract IdentityType for referenceType " + refType.getName());
            return null;
        }
        
        refConfig.setExternalKeyFields(new ArrayList<KeyFieldDef>());
    }
    return refConfig;
}
 
Example #24
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaElement generateWrapper(QName el, XmlSchemaSequence wrappingSequence) {
    XmlSchemaComplexType schemaComplexType = new XmlSchemaComplexType(schema, false);
    schemaComplexType.setParticle(wrappingSequence);

    XmlSchemaElement wrappingSchemaElement = new XmlSchemaElement(schema, true);
    wrappingSchemaElement.setName(el.getLocalPart());
    wrappingSchemaElement.setSchemaType(schemaComplexType);

    return wrappingSchemaElement;
}
 
Example #25
Source File: BeanTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testNillableIntMinOccurs1() throws Exception {
    context = new AegisContext();
    TypeCreationOptions config = new TypeCreationOptions();
    config.setDefaultMinOccurs(1);
    config.setDefaultNillable(false);
    context.setTypeCreationOptions(config);
    context.initialize();
    mapping = context.getTypeMapping();

    BeanType type = (BeanType)mapping.getTypeCreator().createType(IntBean.class);
    type.setTypeClass(IntBean.class);
    type.setTypeMapping(mapping);

    XmlSchema schema = newXmlSchema("urn:Bean");
    type.writeSchema(schema);

    XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("IntBean");
    XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
    boolean int1ok = false;
    for (int x = 0; x < seq.getItems().size(); x++) {
        XmlSchemaSequenceMember o = seq.getItems().get(x);
        if (o instanceof XmlSchemaElement) {
            XmlSchemaElement oe = (XmlSchemaElement) o;
            if ("int1".equals(oe.getName())) {
                int1ok = true;
                assertFalse(oe.isNillable());
                assertEquals(1, oe.getMinOccurs());
            }
        }
    }
    assertTrue(int1ok);
}
 
Example #26
Source File: ParamDclVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaElement addElement(XmlSchemaSequence schemaSequence,
                                    XmlSchemaType schemaType,
                                    String name,
                                    Scope fullyQualifiedName) {
    XmlSchemaElement element = new XmlSchemaElement(schema, false);
    element.setName(name);
    if (schemaType == null) {
        ParamDeferredAction elementAction;
        if (mapper.isDefaultMapping()) {
            elementAction = new ParamDeferredAction(element);
        } else {
            elementAction = new ParamDeferredAction(element,
                                                    fullyQualifiedName.getParent(),
                                                    schema,
                                                    schemas,
                                                    manager,
                                                    mapper);
        }
        wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);

        //ParamDeferredAction elementAction =
        //    new ParamDeferredAction(element);
        //wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
    } else {
        element.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }
    }
    schemaSequence.getItems().add(element);
    return element;
}
 
Example #27
Source File: ServiceModelUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static List<String> getOperationInputPartNames(OperationInfo operation) {
    List<String> names = new ArrayList<>();
    List<MessagePartInfo> parts = operation.getInput().getMessageParts();
    if (parts == null || parts.isEmpty()) {
        return names;
    }

    for (MessagePartInfo part : parts) {
        XmlSchemaAnnotated schema = part.getXmlSchema();

        if (schema instanceof XmlSchemaElement
            && ((XmlSchemaElement)schema).getSchemaType() instanceof XmlSchemaComplexType) {
            XmlSchemaElement element = (XmlSchemaElement)schema;
            XmlSchemaComplexType cplxType = (XmlSchemaComplexType)element.getSchemaType();
            XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle();
            if (seq == null || seq.getItems() == null) {
                return names;
            }
            for (int i = 0; i < seq.getItems().size(); i++) {
                XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().get(i);
                names.add(elChild.getName());
            }
        } else {
            names.add(part.getConcreteName().getLocalPart());
        }
    }
    return names;
}
 
Example #28
Source File: ArrayType.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public void writeSchema(XmlSchema root) {

    if (isFlat()) {
        return; // there is no extra level of type.
    }
    if (hasDefinedArray(root)) {
        return;
    }

    XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true);
    complex.setName(getSchemaType().getLocalPart());

    XmlSchemaSequence seq = new XmlSchemaSequence();
    complex.setParticle(seq);

    AegisType componentType = getComponentType();
    XmlSchemaElement element = new XmlSchemaElement(root, false);
    element.setName(componentType.getSchemaType().getLocalPart());
    element.setSchemaTypeName(componentType.getSchemaType());

    seq.getItems().add(element);

    if (componentType.isNillable()) {
        element.setNillable(true);
    }

    element.setMinOccurs(getMinOccurs());
    element.setMaxOccurs(getMaxOccurs());

}
 
Example #29
Source File: MapType.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a element in a sequence for the key type and the value type.
 */
private void createElement(XmlSchema schema, XmlSchemaSequence seq, QName name,
                           AegisType type, boolean optional) {
    XmlSchemaElement element = new XmlSchemaElement(schema, false);
    seq.getItems().add(element);
    element.setName(name.getLocalPart());
    element.setSchemaTypeName(type.getSchemaType());
    if (optional) {
        element.setMinOccurs(0);
    } else {
        element.setMinOccurs(1);
    }
    element.setMaxOccurs(1);
}
 
Example #30
Source File: SequenceDeferredAction.java    From cxf with Apache License 2.0 5 votes vote down vote up
public SequenceDeferredAction(Sequence sequenceType,
                              Anonsequence anonSequenceType,
                              XmlSchemaElement elem) {
    anonSequence = anonSequenceType;
    sequence = sequenceType;
    element = elem;
}