private void addCrossImports(XmlSchema schema, XmlSchemaChoice choice) { for (XmlSchemaObjectBase seqMember : choice.getItems()) { if (seqMember instanceof XmlSchemaElement) { addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember); } } } private void addCrossImports(XmlSchema schema, XmlSchemaSequence sequence) {
@Nonnull private XmlSchemaType createAny() { final XmlSchemaComplexType value = new XmlSchemaComplexType(schema, false); final XmlSchemaChoice xmlSchemaSequence = new XmlSchemaChoice(); value.setParticle(xmlSchemaSequence); final List<XmlSchemaChoiceMember> items = xmlSchemaSequence.getItems(); final XmlSchemaAny schemaAny = new XmlSchemaAny(); schemaAny.setMinOccurs(0); schemaAny.setMaxOccurs(UNBOUNDED); schemaAny.setProcessContent(XmlSchemaContentProcessing.SKIP); items.add(schemaAny); return value; } }
/** * A choice is given a name built using its first alternative name (choices * do not have names in the XSD). * * @param xsdChoice the XSD choice * @return a field name to use for this choice in its parent complex type */ private static String getFieldName(XmlSchemaChoice xsdChoice) { for (XmlSchemaChoiceMember alternative : xsdChoice.getItems()) { if (alternative instanceof XmlSchemaElement) { return getFieldName((XmlSchemaElement) alternative) + CHOICE_FIELD_NAME_SUFFIX; } } throw new Xsd2ConverterException( "Choice without any alternative at line " + xsdChoice.getLineNumber()); }
} else if (particle instanceof XmlSchemaChoice) { XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice) particle; List<XmlSchemaChoiceMember> items = ((XmlSchemaChoice) particle).getItems(); if ((xmlSchemaChoice.getMaxOccurs() > 1)) { metainfHolder.registerQNameIndex(choiceQName, metainfHolder.getOrderStartPoint() + 1); metainfHolder.addtStatus(choiceQName, SchemaConstants.PARTICLE_TYPE_ELEMENT); metainfHolder.addMaxOccurs(choiceQName, xmlSchemaChoice.getMaxOccurs()); metainfHolder.addMinOccurs(choiceQName, xmlSchemaChoice.getMinOccurs());
if (xmlSchemaChoice.getItems().size() > 0) { BeanWriterMetaInfoHolder beanWriterMetaInfoHolder = new BeanWriterMetaInfoHolder(); beanWriterMetaInfoHolder.setChoice(true); processChoiceItems(parentElementQName, xmlSchemaChoice.getItems(), beanWriterMetaInfoHolder, false, parentSchema); beanWriterMetaInfoHolder.setParticleClass(true); Boolean isArray = xmlSchemaChoice.getMaxOccurs() > 1 ? Boolean.TRUE : Boolean.FALSE; processedElementArrayStatusMap.put(item, isArray); particleQNameMap.put(item, choiceQName);
private XmlSchemaChoice handleChoice(XmlSchema schema, Element choiceEl, Element schemaEl) { XmlSchemaChoice choice = new XmlSchemaChoice(); } else if (el.getLocalName().equals("annotation")) { XmlSchemaAnnotation annotation = handleAnnotation(el); choice.setAnnotation(annotation);
Scope fullyQualifiedName = visitor.getFullyQualifiedName(); XmlSchemaChoice choice = new XmlSchemaChoice(); choice.setMinOccurs(1); choice.setMaxOccurs(1); unionSchemaComplexType.setParticle(choice);
private CorbaType processChoice(XmlSchemaChoice choice, QName defaultName, QName schemaTypeName) throws Exception { QName choicename = null; if (schemaTypeName == null) { choicename = createQNameCorbaNamespace(defaultName.getLocalPart()); } else { choicename = createQNameCorbaNamespace(schemaTypeName.getLocalPart()); } choicename = checkPrefix(choicename); CorbaType corbatype = createUnion(choicename, choice, defaultName, schemaTypeName); String repoId = REPO_STRING + corbatype.getQName().getLocalPart().replace('.', '/') + IDL_VERSION; ((Union)corbatype).setRepositoryID(repoId); if (!(choice.getMaxOccurs() == 1) || !(choice.getMinOccurs() == 1)) { QName name = createQNameTargetNamespace(corbatype.getQName().getLocalPart() + "Array"); CorbaType arrayType = createArray(name, corbatype.getQName(), corbatype.getQName(), choice.getMaxOccurs(), choice.getMinOccurs(), false); if (arrayType != null && !isDuplicate(arrayType)) { typeMappingType.getStructOrExceptionOrUnion().add(arrayType); } } return corbatype; }
} else if (particle instanceof XmlSchemaChoice) { XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice) particle; List<XmlSchemaChoiceMember> items = ((XmlSchemaChoice) particle).getItems(); if ((xmlSchemaChoice.getMaxOccurs() > 1)) { metainfHolder.registerQNameIndex(choiceQName, metainfHolder.getOrderStartPoint() + 1); metainfHolder.addtStatus(choiceQName, SchemaConstants.PARTICLE_TYPE_ELEMENT); metainfHolder.addMaxOccurs(choiceQName, xmlSchemaChoice.getMaxOccurs()); metainfHolder.addMinOccurs(choiceQName, xmlSchemaChoice.getMinOccurs());
if (xmlSchemaChoice.getItems().size() > 0) { BeanWriterMetaInfoHolder beanWriterMetaInfoHolder = new BeanWriterMetaInfoHolder(); beanWriterMetaInfoHolder.setChoice(true); processChoiceItems(parentElementQName, xmlSchemaChoice.getItems(), beanWriterMetaInfoHolder, false, parentSchema); beanWriterMetaInfoHolder.setParticleClass(true); Boolean isArray = xmlSchemaChoice.getMaxOccurs() > 1 ? Boolean.TRUE : Boolean.FALSE; processedElementArrayStatusMap.put(item, isArray); particleQNameMap.put(item, choiceQName);
private XmlSchemaChoice handleChoice(XmlSchema schema, Element choiceEl, Element schemaEl) { XmlSchemaChoice choice = new XmlSchemaChoice(); } else if (el.getLocalName().equals("annotation")) { XmlSchemaAnnotation annotation = handleAnnotation(el); choice.setAnnotation(annotation);
XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice) child; QName choiceQName = particleQNameMap.get(child); boolean isArray = xmlSchemaChoice.getMaxOccurs() > 1; metainfHolder.addMaxOccurs(choiceQName, xmlSchemaChoice.getMaxOccurs()); metainfHolder.addMinOccurs(choiceQName, xmlSchemaChoice.getMinOccurs()); metainfHolder.setHasParticleType(true);
private void addCrossImports(XmlSchema schema, XmlSchemaChoice choice) { for (XmlSchemaObjectBase seqMember : choice.getItems()) { if (seqMember instanceof XmlSchemaElement) { addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember); } } } private void addCrossImports(XmlSchema schema, XmlSchemaSequence sequence) {
@Nonnull private XmlSchemaType createAny() { final XmlSchemaComplexType value = new XmlSchemaComplexType(schema, false); final XmlSchemaChoice xmlSchemaSequence = new XmlSchemaChoice(); value.setParticle(xmlSchemaSequence); final List<XmlSchemaChoiceMember> items = xmlSchemaSequence.getItems(); final XmlSchemaAny schemaAny = new XmlSchemaAny(); schemaAny.setMinOccurs(0); schemaAny.setMaxOccurs(UNBOUNDED); schemaAny.setProcessContent(XmlSchemaContentProcessing.SKIP); items.add(schemaAny); return value; } }
private XmlSchemaChoice handleChoice(XmlSchema schema, Element choiceEl, Element schemaEl) { XmlSchemaChoice choice = new XmlSchemaChoice(); } else if (el.getLocalName().equals("annotation")) { XmlSchemaAnnotation annotation = handleAnnotation(el); choice.setAnnotation(annotation);
XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice) child; QName choiceQName = particleQNameMap.get(child); boolean isArray = xmlSchemaChoice.getMaxOccurs() > 1; metainfHolder.addMaxOccurs(choiceQName, xmlSchemaChoice.getMaxOccurs()); metainfHolder.addMinOccurs(choiceQName, xmlSchemaChoice.getMinOccurs()); metainfHolder.setHasParticleType(true);
private void addCrossImports(XmlSchema schema, XmlSchemaChoice choice) { for (XmlSchemaObjectBase seqMember : choice.getItems()) { if (seqMember instanceof XmlSchemaElement) { addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember); } } } private void addCrossImports(XmlSchema schema, XmlSchemaSequence sequence) {
private void addCrossImports(XmlSchema schema, XmlSchemaChoice choice) { for (XmlSchemaObjectBase seqMember : choice.getItems()) { if (seqMember instanceof XmlSchemaElement) { addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember); } } } private void addCrossImports(XmlSchema schema, XmlSchemaSequence sequence) {
private void addCrossImports(XmlSchema schema, XmlSchemaChoice choice) { for (XmlSchemaObject seqMember : choice.getItems()) { if (seqMember instanceof XmlSchemaElement) { addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember); } } } private void addCrossImports(XmlSchema schema, XmlSchemaSequence sequence) {
/** * Visit each alternative of a choice in turn. * <p/> * Note that this produces a new complex type. * * @param xsdChoice the XML schema choice * @param compositeTypes the lists of composite types being populated * @param choiceTypeName the name to use for this choice type */ private void visit(XmlSchemaChoice xsdChoice, RootCompositeType compositeTypes, String choiceTypeName) { Map < String, Object > alternatives = new LinkedHashMap < String, Object >(); int fieldIndex = 0; for (XmlSchemaChoiceMember alternative : xsdChoice.getItems()) { if (alternative instanceof XmlSchemaElement) { addField(fieldIndex, alternative, alternatives, compositeTypes); fieldIndex++; } } compositeTypes.choiceTypes.put(choiceTypeName, alternatives); }