Java Code Examples for org.apache.ws.commons.schema.XmlSchemaComplexType#setName()

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaComplexType#setName() . 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: 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 2
Source File: JAXBSchemaInitializer.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void buildGenericElements(XmlSchema schema, XmlSchemaSequence seq, Field f) {
    XmlSchemaComplexType generics = new XmlSchemaComplexType(schema, true);
    Type type = f.getGenericType();
    String rawType = ((ParameterizedType)type).getRawType().toString();
    String typeName = StringUtils.uncapitalize(rawType.substring(rawType.lastIndexOf('.') + 1));
    generics.setName(typeName);

    Class<?> genericsClass = f.getType();
    buildGenericSeq(schema, generics, genericsClass);

    String name = Character.toLowerCase(f.getName().charAt(0)) + f.getName().substring(1);
    XmlSchemaElement newel = new XmlSchemaElement(schema, false);
    newel.setName(name);
    newel.setSchemaTypeName(generics.getQName());
    newel.setMinOccurs(0);
    if (!seq.getItems().contains(newel)) {
        seq.getItems().add(newel);
    }
}
 
Example 3
Source File: ArrayVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaComplexType generateSchemaArray(Scope scopedName, Long size,
                                                 XmlSchemaType type, Scope fQName) {
    XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true);
    complexType.setName(mapper.mapToQName(scopedName));

    XmlSchemaSequence sequence = new XmlSchemaSequence();

    XmlSchemaElement element = new XmlSchemaElement(schema, false);
    element.setMinOccurs(size);
    element.setMaxOccurs(size);
    element.setName(ELEMENT_NAME);
    if (type != null) {
        element.setSchemaTypeName(type.getQName());
        if (type.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }
    } else {
        ArrayDeferredAction arrayAction =
            new ArrayDeferredAction(element);
        wsdlVisitor.getDeferredActions().add(fQName, arrayAction);
    }

    sequence.getItems().add(element);

    complexType.setParticle(sequence);

    return complexType;
}
 
Example 4
Source File: SequenceVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaType generateSchemaType(XmlSchemaType stype, Scope scopedName,
                                         long bound, Scope fullyQualifiedName) {
    XmlSchemaComplexType ct = new XmlSchemaComplexType(schema, true);
    ct.setName(mapper.mapToQName(scopedName));
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    XmlSchemaElement el = new XmlSchemaElement(schema, false);
    el.setName(ELEMENT_NAME);
    el.setMinOccurs(0);
    if (bound != -1) {
        el.setMaxOccurs(bound);
    } else {
        el.setMaxOccurs(Long.MAX_VALUE);
    }
    if (stype != null) {
        el.setSchemaTypeName(stype.getQName());
        if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            el.setNillable(true);
        }
    } else {
        SequenceDeferredAction elementAction =
            new SequenceDeferredAction(el);
        wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
    }
    sequence.getItems().add(el);
    ct.setParticle(sequence);
    return ct;
}
 
Example 5
Source File: StructVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void visitDeclaredStruct(AST identifierNode) {
    Scope structScope = new Scope(getScope(), identifierNode);

    // xmlschema:struct
    XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true);
    complexType.setName(mapper.mapToQName(structScope));
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    complexType.setParticle(sequence);

    // corba:struct
    Struct struct = new Struct();
    struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString()));
    struct.setType(complexType.getQName());
    struct.setRepositoryID(structScope.toIDLRepositoryID());

    boolean recursiveAdd = addRecursiveScopedName(identifierNode);

    // struct members
    visitStructMembers(identifierNode, struct, sequence, structScope);

    if (recursiveAdd) {
        removeRecursiveScopedName(identifierNode);
    }

    // add corbaType
    typeMap.getStructOrExceptionOrUnion().add(struct);

    // REVISIT: are there assignment needed?
    setSchemaType(complexType);
    setCorbaType(struct);

    // Need to check if the struct was forward declared
    processForwardStructActions(structScope);

    // Once we've finished declaring the struct, we should make sure it has been removed from
    // the list of scopedNames so that we inidicate that is no longer simply forward declared.
    scopedNames.remove(structScope);
}
 
Example 6
Source File: DeclaratorVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaComplexType duplicateXmlSchemaComplexType(Scope newScope) {
    XmlSchemaComplexType oldSchemaType = (XmlSchemaComplexType) getSchemaType();
    XmlSchemaComplexType newSchemaType = new XmlSchemaComplexType(schema, true);

    newSchemaType.setName(newScope.toString());
    newSchemaType.setParticle(oldSchemaType.getParticle());

    return newSchemaType;
}
 
Example 7
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 8
Source File: ImportRepairTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void createTypeImportingElement(XmlSchema importingSchema) {
    XmlSchemaComplexType typeWithElementRef = new XmlSchemaComplexType(importingSchema, true);
    typeWithElementRef.setName("typeWithRef");
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    typeWithElementRef.setParticle(sequence);
    XmlSchemaElement refElement = new XmlSchemaElement(importingSchema, false);
    refElement.getRef().setTargetQName(new QName(ELEMENT_SCHEMA, "importedElement"));
}
 
Example 9
Source File: ImportRepairTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void createDerivedType2(XmlSchema importingSchema) {
    XmlSchemaComplexContent complexContent;
    XmlSchemaComplexType derivedType2 = new XmlSchemaComplexType(importingSchema, true);
    derivedType2.setName("derivedRestriction");
    XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction();
    restriction.setBaseTypeName(new QName(BASE_TYPE_SCHEMA2, "baseType2"));
    complexContent = new XmlSchemaComplexContent();
    complexContent.setContent(restriction);
    derivedType2.setContentModel(complexContent);
}
 
Example 10
Source File: ImportRepairTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaComplexContentExtension createDerivedType1(XmlSchema importingSchema) {
    XmlSchemaComplexType derivedType1 = new XmlSchemaComplexType(importingSchema, true);
    derivedType1.setName("derivedExtension");
    XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension();
    extension.setBaseTypeName(new QName(BASE_TYPE_SCHEMA1, "baseType1"));
    XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent();
    complexContent.setContent(extension);
    derivedType1.setContentModel(complexContent);
    return extension;
}
 
Example 11
Source File: ExceptionVisitor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void visit(AST node) {
    // <exception_dcl> ::= "exception" <identifier> "{" <member>* "}"
    // <member> ::= <type_spec> <declarators> ";"

    // <type_spec> visited by TypesVisitor

    // Following should be visited by a separate visitor
    // <declarators> ::= <declarator> { "," <declarator> }*
    // <declarator> ::= <simple_declarator>
    //                | <complex_declarator>
    // <simple_declarator> ::= <identifier>
    // <complex_declarator> ::= <array_declarator>
    // <array_declarator> ::= <identifier> <fixed_array_size>+
    // <fixed_array_size> ::= "[" <positive_int_const> "]"


    AST identifierNode = node.getFirstChild();
    Scope exceptionScope = new Scope(getScope(), identifierNode);

    // xmlschema:exception
    Scope scopedName = new Scope(getScope(), identifierNode);
    String exceptionName = mapper.mapToQName(scopedName);
    XmlSchemaElement element = new XmlSchemaElement(schema, true);
    element.setName(mapper.mapToQName(scopedName));

    String exceptionTypeName = exceptionName + TYPE_SUFFIX;

    XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true);
    complexType.setName(exceptionTypeName);
    //complexType.setQName(new QName(schema.getTargetNamespace(), exceptionTypeName));
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    complexType.setParticle(sequence);

    element.setSchemaTypeName(complexType.getQName());

    // corba:exception
    org.apache.cxf.binding.corba.wsdl.Exception exception
        = new org.apache.cxf.binding.corba.wsdl.Exception();
    exception.setQName(new QName(typeMap.getTargetNamespace(), exceptionName));
    exception.setType(complexType.getQName());
    exception.setRepositoryID(scopedName.toIDLRepositoryID());


    // exception members
    AST memberTypeNode = identifierNode.getNextSibling();
    while (memberTypeNode != null) {
        AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);

        TypesVisitor visitor = new TypesVisitor(exceptionScope,
                                                definition,
                                                schema,
                                                wsdlVisitor,
                                                null);
        visitor.visit(memberTypeNode);
        XmlSchemaType stype = visitor.getSchemaType();
        CorbaType ctype = visitor.getCorbaType();
        Scope fullyQualifiedName = visitor.getFullyQualifiedName();

        // needed for anonymous arrays in exceptions
        if (ArrayVisitor.accept(memberNode)) {
            Scope anonScope = new Scope(exceptionScope,
                                        TypesUtils.getCorbaTypeNameNode(memberTypeNode));
            ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,
                                                         definition,
                                                         schema,
                                                         wsdlVisitor,
                                                         null,
                                                         fullyQualifiedName);
            arrayVisitor.setSchemaType(stype);
            arrayVisitor.setCorbaType(ctype);
            arrayVisitor.visit(memberNode);
            stype = arrayVisitor.getSchemaType();
            ctype = arrayVisitor.getCorbaType();
        }


        XmlSchemaElement member = createElementType(memberNode, stype,
                                                    fullyQualifiedName);
        sequence.getItems().add(member);

        MemberType memberType = createMemberType(memberNode, ctype,
                                                 fullyQualifiedName);
        exception.getMember().add(memberType);


        memberTypeNode = memberNode.getNextSibling();
    }

    // add exception to corba typemap
    typeMap.getStructOrExceptionOrUnion().add(exception);

    setSchemaType(complexType);
    setCorbaType(exception);
    createFaultMessage(element.getQName());
}
 
Example 12
Source File: UnionVisitor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void visitDeclaredUnion(AST identifierNode) {

        Scope unionScope = new Scope(getScope(), identifierNode);
        AST discriminatorNode = identifierNode.getNextSibling();
        AST caseNode = discriminatorNode.getNextSibling();
        // xmlschema:union
        XmlSchemaComplexType unionSchemaComplexType = new XmlSchemaComplexType(schema, true);
        unionSchemaComplexType.setName(mapper.mapToQName(unionScope));

        // REVISIT
        // TEMPORARILY
        // using TypesVisitor to visit <const_type>
        // it should be visited by a SwitchTypeSpecVisitor
        TypesVisitor visitor = new TypesVisitor(getScope(), definition, schema, wsdlVisitor, null);
        visitor.visit(discriminatorNode);
        CorbaType ctype = visitor.getCorbaType();
        Scope fullyQualifiedName = visitor.getFullyQualifiedName();

        XmlSchemaChoice choice = new XmlSchemaChoice();
        choice.setMinOccurs(1);
        choice.setMaxOccurs(1);
        unionSchemaComplexType.setParticle(choice);


        // corba:union
        Union corbaUnion = new Union();
        corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
        corbaUnion.setRepositoryID(unionScope.toIDLRepositoryID());
        corbaUnion.setType(unionSchemaComplexType.getQName());
        if (ctype != null) {
            corbaUnion.setDiscriminator(ctype.getQName());
        } else {
            // Discriminator type is forward declared.
            UnionDeferredAction unionDiscriminatorAction =
                new UnionDeferredAction(corbaUnion);
            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionDiscriminatorAction);
        }

        boolean recursiveAdd = addRecursiveScopedName(identifierNode);

        processCaseNodes(caseNode, unionScope, choice, corbaUnion);

        if (recursiveAdd) {
            removeRecursiveScopedName(identifierNode);
        }

        // add corbaType
        typeMap.getStructOrExceptionOrUnion().add(corbaUnion);

        // REVISIT: are these assignments needed?
        setSchemaType(unionSchemaComplexType);
        setCorbaType(corbaUnion);

        // Need to check if the union was forward declared
        processForwardUnionActions(unionScope);

        // Once we've finished declaring the union, we should make sure it has been removed from
        // the list of scopedNames so that we indicate that is no longer simply forward declared.
        scopedNames.remove(unionScope);
    }
 
Example 13
Source File: ImportRepairTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void createTypeImportedByElement(XmlSchema elementTypeSchema) {
    XmlSchemaComplexType elementImportedType = new XmlSchemaComplexType(elementTypeSchema, true);
    elementImportedType.setName("importedElementType");
    elementImportedType.setParticle(new XmlSchemaSequence());
}
 
Example 14
Source File: ImportRepairTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private XmlSchemaComplexType createBaseType2(XmlSchema baseTypeSchema2) {
    XmlSchemaComplexType baseType2 = new XmlSchemaComplexType(baseTypeSchema2, true);
    baseType2.setName("baseType2");
    baseType2.setParticle(new XmlSchemaSequence());
    return baseType2;
}
 
Example 15
Source File: ImportRepairTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void createBaseType1(XmlSchema baseTypeSchema1) {
    XmlSchemaComplexType baseType1 = new XmlSchemaComplexType(baseTypeSchema1, true);
    baseType1.setName("baseType1");
    baseType1.setParticle(new XmlSchemaSequence());
}