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);
}
}
}
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());
}
}
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;
}
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;
}
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());
}
}
Aggregations