Search in sources :

Example 11 with XmlSchemaChoice

use of org.apache.ws.commons.schema.XmlSchemaChoice in project tomee by apache.

the class SchemaCollection method addCrossImportsType.

private void addCrossImportsType(XmlSchema schema, XmlSchemaType schemaType) {
    // the base type might cross schemas.
    if (schemaType instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaType;
        XmlSchemaUtils.addImportIfNeeded(schema, complexType.getBaseSchemaTypeName());
        addCrossImports(schema, complexType.getContentModel());
        addCrossImportsAttributeList(schema, complexType.getAttributes());
        if (complexType.getParticle() instanceof XmlSchemaChoice) {
            XmlSchemaChoice choice = (XmlSchemaChoice) complexType.getParticle();
            addCrossImports(schema, choice);
        } else if (complexType.getParticle() instanceof XmlSchemaAll) {
            XmlSchemaAll all = (XmlSchemaAll) complexType.getParticle();
            addCrossImports(schema, all);
        } else if (complexType.getParticle() instanceof XmlSchemaSequence) {
            XmlSchemaSequence sequence = (XmlSchemaSequence) complexType.getParticle();
            addCrossImports(schema, sequence);
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 12 with XmlSchemaChoice

use of org.apache.ws.commons.schema.XmlSchemaChoice in project tomee by apache.

the class SchemaCollection method addCrossImports.

private void addCrossImports(XmlSchema schema, XmlSchemaContentModel contentModel) {
    if (contentModel == null) {
        return;
    }
    XmlSchemaContent content = contentModel.getContent();
    if (content == null) {
        return;
    }
    if (content instanceof XmlSchemaComplexContentExtension) {
        XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
        XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
        addCrossImportsAttributeList(schema, extension.getAttributes());
        XmlSchemaParticle particle = extension.getParticle();
        if (particle instanceof XmlSchemaSequence) {
            addCrossImports(schema, (XmlSchemaSequence) particle);
        } else if (particle instanceof XmlSchemaChoice) {
            addCrossImports(schema, (XmlSchemaChoice) particle);
        } else if (particle instanceof XmlSchemaAll) {
            addCrossImports(schema, (XmlSchemaAll) particle);
        }
    } else if (content instanceof XmlSchemaComplexContentRestriction) {
        XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
        XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
        addCrossImportsAttributeList(schema, restriction.getAttributes());
    } else if (content instanceof XmlSchemaSimpleContentExtension) {
        XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension) content;
        XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
        addCrossImportsAttributeList(schema, extension.getAttributes());
    } else if (content instanceof XmlSchemaSimpleContentRestriction) {
        XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) content;
        XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
        addCrossImportsAttributeList(schema, restriction.getAttributes());
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaContent(org.apache.ws.commons.schema.XmlSchemaContent) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaComplexContentRestriction(org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaSimpleContentRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction)

Example 13 with XmlSchemaChoice

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

the class WSDLToCorbaHelper method processComplexContentStructParticle.

private Struct processComplexContentStructParticle(XmlSchemaParticle extype, QName defaultName, Struct corbaStruct, QName schematypeName, QName extName, List<XmlSchemaAttributeOrGroupRef> list) throws Exception {
    String uri;
    if (schematypeName != null) {
        uri = schematypeName.getNamespaceURI();
    } else {
        uri = defaultName.getNamespaceURI();
    }
    // Add base as a member of this struct
    MemberType memberType = new MemberType();
    memberType.setName(extName.getLocalPart() + "_f");
    if ("anyType".equals(extName.getLocalPart())) {
        memberType.setIdltype(processPrimitiveType(extName).getQName());
    } else {
        memberType.setIdltype(createQNameCorbaNamespace(extName.getLocalPart()));
    }
    corbaStruct.getMember().add(memberType);
    // process attributes at complexContent level
    List<MemberType> attlist1 = processAttributesAsMembers(list, uri);
    for (int i = 0; i < attlist1.size(); i++) {
        MemberType member = attlist1.get(i);
        corbaStruct.getMember().add(member);
    }
    // Process members of Current Type
    if (extype instanceof XmlSchemaChoice) {
        XmlSchemaChoice choice = (XmlSchemaChoice) extype;
        MemberType choicemem = processComplexContentStructChoice(choice, schematypeName, defaultName);
        choicemem.setAnonschematype(true);
        corbaStruct.getMember().add(choicemem);
    } else if (extype instanceof XmlSchemaSequence) {
        XmlSchemaSequence seq = (XmlSchemaSequence) extype;
        corbaStruct = processComplexContentStructSequence(corbaStruct, seq, defaultName, schematypeName);
    } else if (extype instanceof XmlSchemaAll) {
        XmlSchemaAll all = (XmlSchemaAll) extype;
        corbaStruct = processComplexContentStructSchemaAll(corbaStruct, all, defaultName, schematypeName);
    }
    return corbaStruct;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice)

Example 14 with XmlSchemaChoice

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

the class ParticleInfo method forLocalItem.

/**
 * Fill in an ElementInfo for an element or xs:any from a sequence.
 *
 * @param sequenceObject
 * @param currentSchema
 * @param schemaCollection
 * @param prefixAccumulator
 * @param contextName
 * @return
 */
public static ParticleInfo forLocalItem(XmlSchemaObject sequenceObject, XmlSchema currentSchema, SchemaCollection schemaCollection, NamespacePrefixAccumulator prefixAccumulator, QName contextName) {
    XmlSchemaParticle sequenceParticle = JavascriptUtils.getObjectParticle(sequenceObject, contextName, currentSchema);
    ParticleInfo elementInfo = new ParticleInfo();
    XmlSchemaParticle realParticle = sequenceParticle;
    elementInfo.setMinOccurs(sequenceParticle.getMinOccurs());
    elementInfo.setMaxOccurs(sequenceParticle.getMaxOccurs());
    if (sequenceParticle instanceof XmlSchemaElement) {
        XmlSchemaElement sequenceElement = (XmlSchemaElement) sequenceParticle;
        if (sequenceElement.getRef().getTargetQName() != null) {
            XmlSchemaElement refElement = sequenceElement.getRef().getTarget();
            if (refElement == null) {
                Message message = new Message("ELEMENT_DANGLING_REFERENCE", LOG, sequenceElement.getQName(), sequenceElement.getRef().getTargetQName());
                throw new UnsupportedConstruct(message.toString());
            }
            realParticle = refElement;
            elementInfo.global = true;
        }
        elementInfo.nillable = ((XmlSchemaElement) realParticle).isNillable();
    } else if (sequenceParticle instanceof XmlSchemaChoice) {
        XmlSchemaChoice choice = (XmlSchemaChoice) sequenceParticle;
        if (sequenceParticle.getMaxOccurs() > 1) {
            Message message = new Message("GROUP_ELEMENT_MULTI_OCCURS", LOG, sequenceParticle.getClass().getSimpleName());
            throw new UnsupportedConstruct(message.toString());
        }
        elementInfo.children = new LinkedList<>();
        List<XmlSchemaChoiceMember> items = choice.getItems();
        for (XmlSchemaChoiceMember item : items) {
            XmlSchemaObject schemaObject = JavascriptUtils.getObjectParticle((XmlSchemaObject) item, contextName, currentSchema);
            ParticleInfo childParticle = ParticleInfo.forLocalItem(schemaObject, currentSchema, schemaCollection, prefixAccumulator, contextName);
            if (childParticle.isAny()) {
                Message message = new Message("GROUP_ELEMENT_ANY", LOG, sequenceParticle.getClass().getSimpleName());
                throw new UnsupportedConstruct(message.toString());
            }
            childParticle.setMinOccurs(0);
            elementInfo.children.add(childParticle);
        }
    } else if (sequenceParticle instanceof XmlSchemaSequence) {
        XmlSchemaSequence nestedSequence = (XmlSchemaSequence) sequenceParticle;
        if (sequenceParticle.getMaxOccurs() > 1) {
            Message message = new Message("SEQUENCE_ELEMENT_MULTI_OCCURS", LOG, sequenceParticle.getClass().getSimpleName());
            throw new UnsupportedConstruct(message.toString());
        }
        elementInfo.children = new LinkedList<>();
        List<XmlSchemaSequenceMember> items = nestedSequence.getItems();
        for (XmlSchemaSequenceMember item : items) {
            XmlSchemaObject schemaObject = JavascriptUtils.getObjectParticle((XmlSchemaObject) item, contextName, currentSchema);
            ParticleInfo childParticle = ParticleInfo.forLocalItem(schemaObject, currentSchema, schemaCollection, prefixAccumulator, contextName);
            if (childParticle.isAny()) {
                Message message = new Message("SEQUENCE_ELEMENT_ANY", LOG, sequenceParticle.getClass().getSimpleName());
                throw new UnsupportedConstruct(message.toString());
            }
            if (sequenceParticle.getMinOccurs() == 0) {
                childParticle.setMinOccurs(0);
            }
            elementInfo.children.add(childParticle);
        }
    }
    factoryCommon(realParticle, currentSchema, schemaCollection, prefixAccumulator, elementInfo);
    elementInfo.particle = realParticle;
    return elementInfo;
}
Also used : Message(org.apache.cxf.common.i18n.Message) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) LinkedList(java.util.LinkedList) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaChoiceMember(org.apache.ws.commons.schema.XmlSchemaChoiceMember) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) List(java.util.List) LinkedList(java.util.LinkedList)

Example 15 with XmlSchemaChoice

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

the class SchemaCollection method addCrossImports.

private void addCrossImports(XmlSchema schema, XmlSchemaContentModel contentModel) {
    if (contentModel == null) {
        return;
    }
    XmlSchemaContent content = contentModel.getContent();
    if (content == null) {
        return;
    }
    if (content instanceof XmlSchemaComplexContentExtension) {
        XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
        XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
        addCrossImportsAttributeList(schema, extension.getAttributes());
        XmlSchemaParticle particle = extension.getParticle();
        if (particle instanceof XmlSchemaSequence) {
            addCrossImports(schema, (XmlSchemaSequence) particle);
        } else if (particle instanceof XmlSchemaChoice) {
            addCrossImports(schema, (XmlSchemaChoice) particle);
        } else if (particle instanceof XmlSchemaAll) {
            addCrossImports(schema, (XmlSchemaAll) particle);
        }
    } else if (content instanceof XmlSchemaComplexContentRestriction) {
        XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
        XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
        addCrossImportsAttributeList(schema, restriction.getAttributes());
    } else if (content instanceof XmlSchemaSimpleContentExtension) {
        XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension) content;
        XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
        addCrossImportsAttributeList(schema, extension.getAttributes());
    } else if (content instanceof XmlSchemaSimpleContentRestriction) {
        XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) content;
        XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
        addCrossImportsAttributeList(schema, restriction.getAttributes());
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaContent(org.apache.ws.commons.schema.XmlSchemaContent) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice) XmlSchemaComplexContentRestriction(org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaSimpleContentRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction)

Aggregations

XmlSchemaChoice (org.apache.ws.commons.schema.XmlSchemaChoice)15 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)12 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)10 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)8 QName (javax.xml.namespace.QName)6 XmlSchemaAll (org.apache.ws.commons.schema.XmlSchemaAll)6 ArrayList (java.util.ArrayList)3 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)3 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)3 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)3 Union (org.apache.cxf.binding.corba.wsdl.Union)2 XmlSchemaAny (org.apache.ws.commons.schema.XmlSchemaAny)2 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)2 XmlSchemaComplexContentRestriction (org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction)2 XmlSchemaContent (org.apache.ws.commons.schema.XmlSchemaContent)2 XmlSchemaGroupRef (org.apache.ws.commons.schema.XmlSchemaGroupRef)2 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)2 XmlSchemaSequenceMember (org.apache.ws.commons.schema.XmlSchemaSequenceMember)2 XmlSchemaSimpleContentExtension (org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension)2 XmlSchemaSimpleContentRestriction (org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction)2