/** {@inheritDoc}*/ public String getJavascriptName(XmlSchemaComplexType schemaType) { QName typeQName = schemaType.getQName(); return getJavascriptName(typeQName); }
/** * Writes a complex type * * @param complexType * @param metaInfHolder * @throws SchemaCompilationException */ private String writeComplexType(XmlSchemaComplexType complexType, BeanWriterMetaInfoHolder metaInfHolder) throws SchemaCompilationException { String javaClassName = writer.write(complexType.getQName(), processedTypemap, processedGroupTypeMap, metaInfHolder, complexType.isAbstract()); processedTypeMetaInfoMap.put(complexType.getQName(), metaInfHolder); return javaClassName; }
/** * Writes a complex type * * @param complexType * @param metaInfHolder * @throws SchemaCompilationException */ private String writeComplexType(XmlSchemaComplexType complexType, BeanWriterMetaInfoHolder metaInfHolder) throws SchemaCompilationException { String javaClassName = writer.write(complexType.getQName(), processedTypemap, processedGroupTypeMap, metaInfHolder, complexType.isAbstract()); processedTypeMetaInfoMap.put(complexType.getQName(), metaInfHolder); return javaClassName; }
/** * Annotated complex types as group items. * * @param schema the XML Schema being annotated * @param xsdComplexType the XML schema type * @param elc the DOM Element representing the Cobol annotation * @param level the current level in the type hierarchy * @throws XsdMappingException if annotation fails */ public void setComplexTypeAttributes(final XmlSchema schema, final XmlSchemaComplexType xsdComplexType, final Element elc, final int level) throws XsdMappingException { if (_log.isDebugEnabled()) { _log.debug("setComplexTypeAttributes started for type = " + xsdComplexType.getName()); _log.debug(" XmlSchemaType QName = " + xsdComplexType.getQName()); } elc.setAttribute(CobolMarkup.TYPE, CobolType.GROUP_ITEM.name()); if (_log.isDebugEnabled()) { _log.debug(" Cobol type = " + elc.getAttribute(CobolMarkup.TYPE)); } if (_log.isDebugEnabled()) { _log.debug("setComplexTypeAttributes ended for type = " + xsdComplexType.getQName()); } }
/** * handle the complex types which are named * * @param complexType */ private void processNamedComplexSchemaType(XmlSchemaComplexType complexType, XmlSchema parentSchema) throws SchemaCompilationException { if (processedTypemap.containsKey(complexType.getQName()) || baseSchemaTypeMap.containsKey(complexType.getQName())) { return; } // Must do this up front to support recursive types String fullyQualifiedClassName = writer.makeFullyQualifiedClassName(complexType.getQName()); processedTypemap.put(complexType.getQName(), fullyQualifiedClassName); //register that in the schema metainfo bag complexType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, fullyQualifiedClassName); BeanWriterMetaInfoHolder metaInfHolder = processComplexType(complexType.getQName(), complexType, parentSchema); //add this information to the metainfo holder metaInfHolder.setOwnQname(complexType.getQName()); metaInfHolder.setOwnClassName(fullyQualifiedClassName); //write the class. This type mapping would have been populated right now //Note - We always write classes for named complex types writeComplexType(complexType, metaInfHolder); }
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 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); } }
/** * Process an XML schema complex type. * * @param schema the XML Schema * @param jaxbNamespace the JAXB namespace * @param jaxbNamespacePrefix the JAXB namespace prefix * @param xsdComplexType the XML Schema type to process */ protected void processComplexType(final XmlSchema schema, final String jaxbNamespace, final String jaxbNamespacePrefix, final XmlSchemaComplexType xsdComplexType) { if (_log.isDebugEnabled()) { _log.debug("process started for complex type = " + xsdComplexType.getName()); } processParticle(schema, jaxbNamespace, jaxbNamespacePrefix, xsdComplexType.getQName(), xsdComplexType.getParticle()); if (_log.isDebugEnabled()) { _log.debug("process ended for complex type = " + xsdComplexType.getName()); } }
public void complexTypeConstructorAndAccessors(QName name, XmlSchemaComplexType type) { accessors = new StringBuilder(); utils = new JavascriptUtils(code); List<XmlSchemaObject> items = JavascriptUtils.getContentElements(type, xmlSchemaCollection); List<XmlSchemaAnnotated> attrs = XmlSchemaUtils.getContentAttributes(type, xmlSchemaCollection); final String elementPrefix = "this._"; String typeObjectName = nameManager.getJavascriptName(name); code.append("//\n"); code.append("// Constructor for XML Schema item " + name.toString() + "\n"); code.append("//\n"); code.append("function " + typeObjectName + " () {\n"); // to assist in debugging we put a type property into every object. utils.appendLine("this.typeMarker = '" + typeObjectName + "';"); for (XmlSchemaObject thing : items) { ParticleInfo itemInfo = ParticleInfo.forLocalItem(thing, xmlSchema, xmlSchemaCollection, prefixAccumulator, type.getQName()); constructItem(type, elementPrefix, typeObjectName, itemInfo); } for (XmlSchemaAnnotated thing : attrs) { AttributeInfo itemInfo = AttributeInfo.forLocalItem(thing, xmlSchema, xmlSchemaCollection, prefixAccumulator, type.getQName()); constructOneItem(type, elementPrefix, typeObjectName, itemInfo); } code.append("}\n\n"); code.append(accessors.toString()); }
private void buildGenericElements(XmlSchema schema, XmlSchemaSequence seq, Method m, Type type) { String rawType = ((ParameterizedType)type).getRawType().toString(); String typeName = StringUtils.uncapitalize(rawType.substring(rawType.lastIndexOf(".") + 1)); XmlSchemaComplexType generics = (XmlSchemaComplexType)schema.getTypeByName(typeName); if (generics == null) { generics = new XmlSchemaComplexType(schema, true); generics.setName(typeName); } Class<?> genericsClass = m.getReturnType(); buildGenericSeq(schema, generics, genericsClass); int idx = m.getName().startsWith("get") ? 3 : 2; String name = m.getName().substring(idx); name = Character.toLowerCase(name.charAt(0)) + name.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); } }
/** * Process an XML schema complex type. * * @param xsdComplexType the XML Schema type to process * @param level the current level in the elements hierarchy. * @throws XsdMappingException if processing fails */ public void processComplexType(final XmlSchemaComplexType xsdComplexType, final int level) throws XsdMappingException { if (_log.isDebugEnabled()) { _log.debug("process started for complex type = " + xsdComplexType.getName()); } /* Delegate processing of XML schema complex type */ _processor.processComplexType(_schema, xsdComplexType, level); /* Complex types might particles such as sequence and all */ XmlSchemaParticle particle = xsdComplexType.getParticle(); processParticle(xsdComplexType.getQName(), particle, level + XsdConstants.DEFAULT_LEVEL_INCREMENT); if (_log.isDebugEnabled()) { _log.debug("process ended for complex type = " + xsdComplexType.getName()); } }
private CorbaType processComplexType(XmlSchemaComplexType complex, QName defaultName, XmlSchemaAnnotation annotation, boolean anonymous) throws Exception { CorbaType corbatype = null; if (isLiteralArray(complex)) { corbatype = processLiteralArray(complex, defaultName, anonymous); } else if (WSDLTypes.isOMGUnion(complex)) { corbatype = processOMGUnion(complex, defaultName); } else if (WSDLTypes.isUnion(complex)) { corbatype = processRegularUnion(complex, defaultName); } else if (complex.getQName() != null && isIDLObjectType(complex.getQName())) { // process it. corbatype = WSDLTypes.processObject(def, complex, annotation, checkPrefix(complex.getQName()), defaultName, idlNamespace); } else { // Deal the ComplexType as Struct corbatype = processStruct(complex, defaultName); } return corbatype; }
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.setName(localPartName); boolean disallowAnonTypes = isAnonymousTypesDisallowed(); if (disallowAnonTypes) { String complexTypeName = localPartName.substring(0, 1).toUpperCase() + localPartName.substring(1); complexType.setName(complexTypeName); 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); } typeTable.addComplexSchema(localPartName, elementName); return complexType; }
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.setName(localPartName); boolean disallowAnonTypes = isAnonymousTypesDisallowed(); if (disallowAnonTypes) { String complexTypeName = localPartName.substring(0, 1).toUpperCase() + localPartName.substring(1); complexType.setName(complexTypeName); 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); } typeTable.addComplexSchema(localPartName, elementName); return complexType; }
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 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; }
/** * Build the serialization code for a complex type. At the top level, this operates on single items, so it * does not pay attention to minOccurs and maxOccurs. However, as it works through the sequence, it * manages optional elements and arrays. * * @param type * @param elementPrefix * @param bodyNamespaceURIs * @return */ protected void complexTypeSerializerBody(XmlSchemaComplexType type, String elementPrefix, JavascriptUtils bodyUtils) { List<XmlSchemaObject> items = JavascriptUtils.getContentElements(type, xmlSchemaCollection); for (XmlSchemaObject sequenceItem : items) { ParticleInfo itemInfo = ParticleInfo.forLocalItem(sequenceItem, xmlSchema, xmlSchemaCollection, prefixAccumulator, type.getQName()); // If the item is 'any', it could be ANY of our top-level elements. if (itemInfo.isAny()) { serializeAny(itemInfo, bodyUtils); } else { bodyUtils.generateCodeToSerializeElement(itemInfo, "this._", xmlSchemaCollection); } } }
/** * Creates a new element and complex schema type with the given name and the namespace. * @param cparams The common parameters used in the schema generator * @param parentElement The parent element to where the new element will be added * @param name The name of the element * @param namespace The namespace of the element * @param global Signal if the newly created element is global or not * @return The newly added XML schema element */ private static XmlSchemaElement createAndAddToElement(CommonParams cparams, XmlSchemaElement parentElement, String name, String namespace, boolean global, boolean isArrayElement, boolean optional) { XmlSchemaElement tmpElement = createElement(cparams, namespace, name, global); XmlSchemaComplexType type = createComplexType(cparams, namespace, name, true); tmpElement.setSchemaTypeName(type.getQName()); if (isArrayElement) { addToElement(cparams, parentElement, tmpElement, global, true, optional); } else { addToElement(cparams, parentElement, tmpElement, global, false, optional); } return tmpElement; }
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); }