[Axis2 0.95] Recursive data types and choice particles

2006-03-26 Thread Chuck Williams
Hi All,

Axis2 0.95 still does not handle recursive data types properly.  The
SchemaCompiler recurses infinitely and generates a stack overflow.  I've
attached my patch to fix this upgraded for 0.95.  This is a patch
against modules/codegen/src.

I see that much of the code to implement choice particles was committed,
but that the new parser does not handle them.  I need to get them
working again.  Is there already work underway to do this, and/or was an
approach determined?  If so, I'd appreciate any information about that. 
If not, I'll figure out how to do it with the new parser and send
another patch.

Thanks,

Chuck



Re: [Axis2 0.95] Recursive data types and choice particles

2006-03-26 Thread Chuck Williams




This time with the attachment:



Chuck Williams [EMAIL PROTECTED] wrote on 03/26/2006
01:41:54 AM:



  Hi All,

Axis2 0.95 still does not handle recursive data types properly.  The
SchemaCompiler recurses infinitely and generates a stack overflow.  I've
attached my patch to fix this upgraded for 0.95.  This is a patch
against modules/codegen/src.

I see that much of the code to implement choice particles was committed,
but that the new parser does not handle them.  I need to get them
working again.  Is there already work underway to do this, and/or was an
approach determined?  If so, I'd appreciate any information about that. 
If not, I'll figure out how to do it with the new parser and send
another patch.

Thanks,

Chuck

  




diff -urx '*~' codegen.src.orig/org/apache/axis2/schema/SchemaCompiler.java codegen.src.new/org/apache/axis2/schema/SchemaCompiler.java
--- codegen.src.orig/org/apache/axis2/schema/SchemaCompiler.java	2006-03-25 12:23:50.0 -1000
+++ codegen.src.new/org/apache/axis2/schema/SchemaCompiler.java	2006-03-25 21:55:26.0 -1000
@@ -381,7 +381,8 @@
 //set a name
 schemaType.setName(generatedTypeName.getLocalPart());
 writeComplexType((XmlSchemaComplexType)schemaType,
-(BeanWriterMetaInfoHolder)processedAnonymousComplexTypesMap.get(xsElt));
+(BeanWriterMetaInfoHolder)processedAnonymousComplexTypesMap.get(xsElt),
+null);
 //remove the reference from the anon list since we named the type
 processedAnonymousComplexTypesMap.remove(xsElt);
 innerElementMap.put(
@@ -423,7 +424,8 @@
 referenceSchemaType.setName(generatedTypeName.getLocalPart());
 
 writeComplexType((XmlSchemaComplexType)referenceSchemaType,
-(BeanWriterMetaInfoHolder)processedAnonymousComplexTypesMap.get(referencedElement));
+(BeanWriterMetaInfoHolder)processedAnonymousComplexTypesMap.get(referencedElement),
+null);
 //remove the reference from the anon list since we named the type
 processedAnonymousComplexTypesMap.remove(referencedElement);
 
@@ -600,12 +602,16 @@
 || 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);
 
 BeanWriterMetaInfoHolder metaInfHolder = processComplexType(complexType,parentSchema);
 
 //write the class. This type mapping would have been populated right now
 //Note - We always write classes for named complex types
-writeComplexType(complexType, metaInfHolder);
+writeComplexType(complexType, metaInfHolder, fullyQualifiedClassName);
 
 
 }
@@ -614,12 +620,12 @@
  * Writes a complex type
  * @param complexType
  * @param metaInfHolder
+ * @param fullyQualifiedClassName the name returned by makeFullyQualifiedClassName() or null if it wasn't called
  * @throws SchemaCompilationException
  */
-private void writeComplexType(XmlSchemaComplexType complexType, BeanWriterMetaInfoHolder metaInfHolder) throws SchemaCompilationException {
-String fullyQualifiedClassName = writer.write(complexType, processedTypemap, metaInfHolder);
-//populate the type map with the type QName
-processedTypemap.put(complexType.getQName(), fullyQualifiedClassName);
+private void writeComplexType(XmlSchemaComplexType complexType, BeanWriterMetaInfoHolder metaInfHolder, String fullyQualifiedClassName)
+throws SchemaCompilationException {
+writer.write(complexType, processedTypemap, metaInfHolder, fullyQualifiedClassName);
 processedTypeMetaInfoMap.put(complexType.getQName(),metaInfHolder);
 }
 
diff -urx '*~' codegen.src.orig/org/apache/axis2/schema/writer/BeanWriter.java codegen.src.new/org/apache/axis2/schema/writer/BeanWriter.java
--- codegen.src.orig/org/apache/axis2/schema/writer/BeanWriter.java	2006-03-25 12:23:50.0 -1000
+++ codegen.src.new/org/apache/axis2/schema/writer/BeanWriter.java	2006-03-25 21:55:26.0 -1000
@@ -1,5 +1,6 @@
 package org.apache.axis2.schema.writer;
 
+import javax.xml.namespace.QName;
 import org.apache.axis2.schema.BeanWriterMetaInfoHolder;
 import org.apache.axis2.schema.CompilerOptions;
 import org.apache.axis2.schema.SchemaCompilationException;
@@ -51,6 +52,12 @@
  * of the schema compiler may be exposed.
  */
 public Map getModelMap();
+
+/** Make the fully qualified class name for an element or named type
+ * @param qName the