public static boolean isOMGUnion(XmlSchemaComplexType type) { boolean isUnion = false; if (type.getParticle() instanceof XmlSchemaSequence && type.getAttributes().isEmpty()) { XmlSchemaSequence stype = (XmlSchemaSequence)type.getParticle(); if (stype.getItems().size() == 2) { XmlSchemaParticle st1 = (XmlSchemaParticle)stype.getItems().get(0); XmlSchemaParticle st2 = (XmlSchemaParticle)stype.getItems().get(1); XmlSchemaElement discEl = null; if (st1 instanceof XmlSchemaChoice && st2 instanceof XmlSchemaElement) { isUnion = true; discEl = (XmlSchemaElement)st2; } else if (st2 instanceof XmlSchemaChoice && st1 instanceof XmlSchemaElement) { isUnion = true; discEl = (XmlSchemaElement)st1; } if (isUnion && !"discriminator".equals(discEl.getQName().getLocalPart())) { isUnion = false; } } } return isUnion; }
private static boolean isSoapArray(final XmlSchemaComplexType complexType) { // Soap arrays are based on complex content restriction final XmlSchemaContentModel contentModel = complexType.getContentModel(); if (contentModel == null) { return false; } final XmlSchemaContent content = contentModel.getContent(); if (!(content instanceof XmlSchemaComplexContentRestriction)) { return false; } final XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content; return SOAP_ARRAY.equals(restriction.getBaseTypeName()); }
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; }
private boolean hasAttributes(XmlSchemaComplexType complexType) { // Now lets see if we have any attributes... // This should probably look at the restricted and substitute types too. return complexType.getAnyAttribute() != null || complexType.getAttributes().size() > 0; }
public static boolean isUnion(XmlSchemaComplexType type) { boolean isUnion = false; if (type.getParticle() instanceof XmlSchemaChoice && type.getAttributes().isEmpty()) { isUnion = true; } return isUnion; }
private XmlSchemaSequence getTypeSequence(XmlSchemaComplexType type, QName parentName) { if (!(type.getParticle() instanceof XmlSchemaSequence)) { unsupportedConstruct("NON_SEQUENCE_PARTICLE", type.getQName() != null ? type.getQName() : parentName); } return (XmlSchemaSequence)type.getParticle(); }
boolean isArrayType, String propertyName) { XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false); xmlSchemaElement.setName( name + "Wrapper"); xmlSchemaElement.setNillable(true); sequence.getItems().add(xmlSchemaElement); typeTable.getSimpleSchemaTypeName(propertyName).getLocalPart() + "Wrapper"; xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence(); xmlSchemaComplexType.setParticle(xmlSchemaSequence); xmlSchemaComplexType.setName(complexTypeName); new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()), xmlSchemaComplexType); addElementToSequence("array", xmlSchemaElement.setSchemaType(xmlSchemaComplexType); xmlSchemaElement.setSchemaTypeName(new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()));
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; }
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; }
private XmlSchemaComplexType createSchemaTypeForFault(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setName(localPartName); boolean disallowAnonTypes = isAnonymousTypesDisallowed(); if (disallowAnonTypes) { complexType.setName(localPartName); globalElement.setSchemaTypeName(complexType.getQName()); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().put(complexType.getQName(), complexType); } else { globalElement.setSchemaType(complexType); } xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } return complexType; }
private void generateComplexTypeforException() { XmlSchemaSequence sequence = new XmlSchemaSequence(); XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(schemaTargetNameSpace, "Exception", schema_namespace_prefix); XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false); complexType.setName("Exception"); xmlSchema.getItems().add(complexType); xmlSchema.getSchemaTypes().put(elementName, complexType); typeTable.addComplexSchema(Exception.class.getName(), elementName); QName schemaTypeName = new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "string"); addContentToMethodSchemaType(sequence, schemaTypeName, "Message", false); complexType.setParticle(sequence); }
/** * Generate schema construct for given type * * @param localPartName */ private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName) { XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace); QName elementName = new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix); XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName); if (complexType == null) { complexType = new XmlSchemaComplexType(xmlSchema, false); XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false); globalElement.setSchemaType(complexType); globalElement.setName(localPartName); xmlSchema.getItems().add(globalElement); xmlSchema.getElements().put(elementName, globalElement); } typeTable.addComplexSchema(localPartName, elementName); return complexType; }
@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); }
return null; if (element.isNillable()) { XmlSchemaType type = element.getSchemaType(); if (type == null) { String qName = element.getQName().toString(); throw new InvalidWSDLException("The XML schema element does not have a type: " + qName); if (complexType.getAttributes().getCount() != 0 || complexType.getAnyAttribute() != null) { XmlSchemaParticle particle = complexType.getParticle(); if (particle == null) { return null; XmlSchemaSequence sequence = (XmlSchemaSequence)complexType.getParticle(); XmlSchemaObjectCollection items = sequence.getItems(); List<XmlSchemaElement> childElements = new ArrayList<XmlSchemaElement>(); for (int i = 0; i < items.getCount(); i++) { if (ANY.equals(childElement.getQName())) {
private CorbaType processRegularUnion(XmlSchemaComplexType complex, QName defaultName) throws Exception { //NEED TO DO QName name = null; QName schematypeName = complex.getQName(); if (schematypeName == null) { schematypeName = defaultName; name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type"); } else { name = createQNameCorbaNamespace(schematypeName.getLocalPart()); } return createUnion(name, (XmlSchemaChoice)complex.getParticle(), defaultName, schematypeName); }
private void processAttributes(XmlSchemaComplexType complexType, AxisMessage message, List partNameList, String qnameSuffix) { QName opName = message.getAxisOperation().getName(); XmlSchemaAttribute xmlSchemaAttribute; for (XmlSchemaObject item : complexType.getAttributes()) { if (item instanceof XmlSchemaAttribute) { xmlSchemaAttribute = (XmlSchemaAttribute) item; String partName = xmlSchemaAttribute.getName(); partNameList.add( WSDLUtil.getPartQName(opName.getLocalPart(), qnameSuffix, partName)); } } }
for (XmlSchema schemaInfo : xmlSchemaCollection.getXmlSchemas()) { for (Map.Entry<QName, XmlSchemaElement> e : schemaInfo.getElements().entrySet()) { QName name = e.getKey(); if (JavascriptUtils.notVeryComplexType(element.getSchemaType())) { continue; XmlSchemaComplexType elementType = (XmlSchemaComplexType)element.getSchemaType(); if (elementType != null && elementType.getQName() != null) { name = elementType.getQName(); utils.appendLine("this.globalElementSerializers['" + name.toString() + "'] = " + nameManager.getJavascriptName(name) + "_serialize;"); utils.appendLine("this.globalElementDeserializers['" + name.toString() + "'] = " + nameManager.getJavascriptName(name) + "_deserialize;"); utils.appendLine("this.globalElementSerializers['" + name.toString() + "'] = " + nameManager.getJavascriptName(name) + "_serialize;");
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()); // could it be a choice or something else? 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); } } } private void addCrossImports(XmlSchema schema, XmlSchemaAll all) {
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); } }
SchemaCollection schema = serviceInfo.getXmlSchemaCollection(); XmlSchemaElement elementByName = schema.getElementByQName(partElement); XmlSchemaComplexType type = (XmlSchemaComplexType)elementByName.getSchemaType(); XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle(); if (seq == null && type.getContentModel() != null) { XmlSchemaContent xmlSchemaConent = type.getContentModel().getContent(); if (xmlSchemaConent instanceof XmlSchemaComplexContentExtension) { XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)type .getContentModel().getContent(); QName baseTypeName = extension.getBaseTypeName(); XmlSchemaType schemaType = schema.getTypeByQName(baseTypeName); if (schemaType instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaType; if (complexType.getParticle() instanceof XmlSchemaSequence) { seq = (XmlSchemaSequence)complexType.getParticle(); qnames.addAll(createWrappedElements(seq)); if (extension.getParticle() instanceof XmlSchemaSequence) { XmlSchemaSequence xmlSchemaSeq = (XmlSchemaSequence)extension.getParticle(); qnames.addAll(createWrappedElements(xmlSchemaSeq));