You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/10/20 08:36:55 UTC

svn commit: r326840 - in /webservices/axis2/trunk/java/modules/codegen: src/org/apache/axis2/databinding/schema/ src/org/apache/axis2/databinding/schema/template/ src/org/apache/axis2/wsdl/codegen/extension/ src/org/apache/axis2/wsdl/template/java/ tes...

Author: ajith
Date: Wed Oct 19 23:36:16 2005
New Revision: 326840

URL: http://svn.apache.org/viewcvs?rev=326840&view=rev
Log:
1.Added support for minOccurs/maxOccurs (Array support) extending the template to generate validation code
2. Added support for anonymous complex types
3. Updated the supporter (not complete yet)

Added:
    webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd
    webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/complex_all.xsd
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/ADBSupporterTemplate.xsl

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java?rev=326840&r1=326839&r2=326840&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/BeanWriterMetaInfoHolder.java Wed Oct 19 23:36:16 2005
@@ -35,6 +35,8 @@
     private Map elementToSchemaQNameMap = new HashMap();
     private Map elementToJavaClassMap = new HashMap();
     private Map specialTypeFlagMap = new HashMap();
+    private Map qNameMaxOccursCountMap = new HashMap();
+    private Map qNameMinOccursCountMap = new HashMap();
 
     public String getExtensionClassName() {
         return extensionClassName;
@@ -94,12 +96,57 @@
         return anyState != null && anyState.equals(SchemaConstants.ANY_ARRAY_TYPE);
     }
 
+    /**
+     *
+     */
     public void clearTables(){
         this.elementToJavaClassMap.clear();
         this.elementToSchemaQNameMap.clear();
 
     }
 
+    /**
+     *
+     * @param qName
+     * @param minOccurs
+     */
+    public void addMinOccurs(QName qName, long minOccurs){
+        this.qNameMinOccursCountMap.put(qName,new Long(minOccurs));
+    }
+
+    /**
+     *
+     * @param qName
+     * @return
+     */
+    public long getMinOccurs(QName qName){
+        Long l =(Long) this.qNameMinOccursCountMap.get(qName);
+        return l!=null?l.longValue():1; //default for min is 1
+    }
+
+    /**
+     * 
+     * @param qName
+     * @return
+     */
+    public long getMaxOccurs(QName qName){
+        Long l =(Long) this.qNameMaxOccursCountMap.get(qName);
+        return l!=null?l.longValue():1; //default for max is 1
+    }
+
+    /**
+     *
+     * @param qName
+     * @param maxOccurs
+     */
+    public void addMaxOccurs(QName qName, long maxOccurs){
+        this.qNameMaxOccursCountMap.put(qName,new Long(maxOccurs));
+    }
+
+    /**
+     *
+     * @return
+     */
     public Iterator getElementQNameIterator(){
         return elementToJavaClassMap.keySet().iterator();
     }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java?rev=326840&r1=326839&r2=326840&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java Wed Oct 19 23:36:16 2005
@@ -150,11 +150,23 @@
             }
 
             if (metainf.getArrayStatusForQName(name)){
-                  XSLTUtils.addAttribute(model,"array","yes",property);
+                XSLTUtils.addAttribute(model,"array","yes",property);
+                long minOccurs = metainf.getMinOccurs(name);
+
+                if (minOccurs >0){
+                  XSLTUtils.addAttribute(model,"minOccurs",minOccurs +"",property);
+                }
+
+                long maxOccurs = metainf.getMaxOccurs(name);
+                if (maxOccurs==Long.MAX_VALUE){
+                     XSLTUtils.addAttribute(model,"unbound","yes",property);
+                }else{
+                    XSLTUtils.addAttribute(model,"maxOccurs",maxOccurs +"",property);
+                }
             }
         }
 
-
+        System.out.println("rootElt = " + rootElt);
         //create the file
         OutputStream out = createOutFile(packageName,className);
         //parse with the template and create the files

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java?rev=326840&r1=326839&r2=326840&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java Wed Oct 19 23:36:16 2005
@@ -26,20 +26,22 @@
 
     private CompilerOptions options;
     private HashMap processedTypemap;
-    //The processedElementmap and the processedElementList have a subtle difference
+    //The processedElementMap and the processedElementList have a subtle difference
     //The writing to the processedElementList happens when an outer element is processed.
     //
-    private HashMap processedElementmap;
+    private HashMap processedElementMap;
+    private HashMap processedAnonymousComplexTypesMap;
     private ArrayList processedElementList;
 
+
     private JavaBeanWriter writer;
 
     private Map baseSchemaTypeMap = TypeMap.getTypeMap();
     private static final String ANY_ELEMENT_FIELD_NAME = "extraElements";
 
 
-    public HashMap getProcessedElementmap() {
-        return processedElementmap;
+    public HashMap getProcessedElementMap() {
+        return processedElementMap;
     }
 
     /**
@@ -56,8 +58,9 @@
             }
 
             this.processedTypemap = new HashMap();
-            this.processedElementmap = new HashMap();
+            this.processedElementMap = new HashMap();
             this.processedElementList = new ArrayList();
+            this.processedAnonymousComplexTypesMap = new HashMap();
 
             this.writer = new JavaBeanWriter(this.options.getOutputLocation());
 
@@ -116,23 +119,38 @@
 
     }
 
-    private void writeElement(XmlSchemaElement schemaElement) throws SchemaCompilationException{
-        if (this.processedElementmap.containsKey(schemaElement.getQName())){
+    /**
+     * Writes the element
+     * @param xsElt
+     * @throws SchemaCompilationException
+     */
+    private void writeElement(XmlSchemaElement xsElt) throws SchemaCompilationException{
+        if (this.processedElementMap.containsKey(xsElt.getQName())){
             return;
         }
 
-        XmlSchemaType schemaType = schemaElement.getSchemaType();
+        XmlSchemaType schemaType = xsElt.getSchemaType();
 
         if (schemaType!=null){
             BeanWriterMetaInfoHolder metainf = new BeanWriterMetaInfoHolder();
-            QName qName = schemaType.getQName();
-            //find the class name
-            String className = findClassName(schemaType,isArray(schemaElement));
-            metainf.registerMapping(schemaElement.getQName(),
-                    qName,
-                    className);
-            String writtenClassName = writer.write(schemaElement,processedTypemap,metainf);
-            processedElementmap.put(schemaElement.getQName(),writtenClassName);
+            if (schemaType.getName()!=null){
+                //this is a named type
+                QName qName = schemaType.getQName();
+                //find the class name
+                String className = findClassName(schemaType,isArray(xsElt));
+                metainf.registerMapping(xsElt.getQName(),
+                        qName,
+                        className);
+
+            }else{
+                //we are going to special case the anonymous complex type. Our algorithm for dealing
+                //with it is to generate a single object that has the complex content inside. Really the
+                //intent of the user when he declares the complexType anonymously is to use it privately
+                //First copy the schema types content into the metainf holder
+                metainf = (BeanWriterMetaInfoHolder)this.processedAnonymousComplexTypesMap.get(xsElt);
+            }
+            String writtenClassName = writer.write(xsElt,processedTypemap,metainf);
+            processedElementMap.put(xsElt.getQName(),writtenClassName);
         }
     }
 
@@ -165,7 +183,7 @@
         XmlSchemaType schemaType = xsElt.getSchemaType();
 
         if (schemaType!=null){
-            processSchema(schemaType);
+            processSchema(xsElt,schemaType);
 
             //at this time it is not wise to directly write the class for the element
             //so we push the complete element to an arraylist and let the process
@@ -174,13 +192,13 @@
 
             if (!isOuter){
                 String className = findClassName(schemaType,isArray);
-                this.processedElementmap.put(xsElt.getQName(),className);
+                this.processedElementMap.put(xsElt.getQName(),className);
             }
             this.processedElementList.add(xsElt.getQName());
 
         }else{
-            //perhaps this has an anonymous complex type! Handle it here
-            //BTW how do we handle an anonymous complex type
+            //what do we do when the schematype is missing ??
+
         }
 
     }
@@ -216,21 +234,63 @@
      * @param schemaType
      * @throws SchemaCompilationException
      */
-    private void processSchema(XmlSchemaType schemaType) throws SchemaCompilationException {
+    private void processSchema(XmlSchemaElement xsElt,XmlSchemaType schemaType) throws SchemaCompilationException {
         if (schemaType instanceof XmlSchemaComplexType){
             //write classes for complex types
-            processComplexSchemaType((XmlSchemaComplexType)schemaType);
+            XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaType;
+            if (complexType.getName()!=null){
+                processNamedComplexSchemaType(complexType);
+            }else{
+                processAnonymousComplexSchemaType(xsElt,complexType);
+            }
         }else if (schemaType instanceof XmlSchemaSimpleType){
             //process simple type
             processSimpleSchemaType((XmlSchemaSimpleType)schemaType);
         }
     }
 
+
+    /**
+     *
+     * @param complexType
+     * @throws SchemaCompilationException
+     */
+    private void processAnonymousComplexSchemaType(XmlSchemaElement elt,XmlSchemaComplexType complexType) throws SchemaCompilationException{
+        XmlSchemaParticle particle =  complexType.getParticle();
+        BeanWriterMetaInfoHolder metaInfHolder = new BeanWriterMetaInfoHolder();
+        if (particle!=null){
+            //Process the particle
+            processParticle(particle, metaInfHolder);
+        }
+
+        //process attributes - first look for the explicit attributes
+        XmlSchemaObjectCollection attribs = complexType.getAttributes();
+        Iterator attribIterator = attribs.getIterator();
+        while (attribIterator.hasNext()) {
+            Object o =  attribIterator.next();
+            if (o instanceof XmlSchemaAttribute){
+                processAttribute((XmlSchemaAttribute)o,metaInfHolder);
+
+            }
+        }
+
+        //process any attribute
+        //somehow the xml schema parser does not seem to pickup the any attribute!!
+        XmlSchemaAnyAttribute anyAtt = complexType.getAnyAttribute();
+        if (anyAtt!=null){
+            processAnyAttribute(metaInfHolder);
+        }
+
+        //since this is a special case (an unnamed complex type) we'll put the already processed
+        //metainf holder in a special map to be used later
+        this.processedAnonymousComplexTypesMap.put(elt,metaInfHolder);
+    }
+
     /**
-     * handle the complex type
+     * handle the complex types which are named
      * @param complexType
      */
-    private void processComplexSchemaType(XmlSchemaComplexType complexType) throws SchemaCompilationException{
+    private void processNamedComplexSchemaType(XmlSchemaComplexType complexType) throws SchemaCompilationException{
 
         if (processedTypemap.containsKey(complexType.getQName())
                 || baseSchemaTypeMap.containsKey(complexType.getQName())){
@@ -358,13 +418,16 @@
         Iterator processedElementsIterator= processedElements.keySet().iterator();
         while(processedElementsIterator.hasNext()){
             XmlSchemaElement elt = (XmlSchemaElement)processedElementsIterator.next();
-            String clazzName = (String)processedElementmap.get(elt.getQName());
+            String clazzName = (String)processedElementMap.get(elt.getQName());
             metainfHolder.registerMapping(elt.getQName(),
                     elt.getSchemaTypeName()
                     ,clazzName,
                     ((Boolean)processedElements.get(elt)).booleanValue()?
                             SchemaConstants.ANY_ARRAY_TYPE:
                             SchemaConstants.ELEMENT_TYPE);
+            //register the occurence counts
+            metainfHolder.addMaxOccurs(elt.getQName(),elt.getMaxOccurs());
+            metainfHolder.addMinOccurs(elt.getQName(),elt.getMinOccurs());
 
         }
         //set the ordered flag in the metainf holder

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl?rev=326840&r1=326839&r2=326840&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/template/BeanTemplate.xsl Wed Oct 19 23:36:16 2005
@@ -1,154 +1,172 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
     <xsl:template match="/bean">
-    package <xsl:value-of select="@package"/>;
-    <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+        package <xsl:value-of select="@package"/>;
+        <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
 
-    /**
-     *  Auto generated bean class by the Axis code generator
-     */
+        /**
+        *  Auto generated bean class by the Axis code generator
+        */
 
-    public class <xsl:value-of select="$name"/> <xsl:if test="@extension"> extends <xsl:value-of select="@extension"/></xsl:if>
+        public class <xsl:value-of select="$name"/> <xsl:if test="@extension"> extends <xsl:value-of select="@extension"/></xsl:if>
         implements org.apache.axis2.databinding.ADBBean{
         <xsl:choose>
             <xsl:when test="@type">/* This type was generated from the piece of schema that had
-                    name = <xsl:value-of select="$name"/>
-                    Namespace URI = <xsl:value-of select="@nsuri"/>
-                    Namespace Prefix = <xsl:value-of select="@nsprefix"/>
+                name = <xsl:value-of select="$name"/>
+                Namespace URI = <xsl:value-of select="@nsuri"/>
+                Namespace Prefix = <xsl:value-of select="@nsprefix"/>
                 */
             </xsl:when>
             <xsl:otherwise>
                 public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
-                                                     "<xsl:value-of select="@nsuri"/>",
-                                                     "<xsl:value-of select="$name"/>",
-                                                     "<xsl:value-of select="@nsprefix"/>");
+                "<xsl:value-of select="@nsuri"/>",
+                "<xsl:value-of select="$name"/>",
+                "<xsl:value-of select="@nsprefix"/>");
 
             </xsl:otherwise>
         </xsl:choose>
-      <xsl:if test="@type"></xsl:if>
-
-     <xsl:for-each select="property">
-         <xsl:variable name="propertyType"><xsl:value-of select="@type"></xsl:value-of></xsl:variable>
-         <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
-         <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
-        /**
-         * field for <xsl:value-of select="$javaName"/>
-         <xsl:if test="@attribute">* This was an Attribute!</xsl:if>
-         <xsl:if test="@array">* This was an Array!</xsl:if>
+        <xsl:if test="@type"></xsl:if>
 
-         */
-         private <xsl:value-of select="$propertyType"/> local<xsl:value-of select="$javaName"/>;
-
-        /**
-         * Auto generated getter method
-         * @return <xsl:value-of select="$propertyType"/>
-         */
-        public  <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of select="$javaName"/>(){
-             return local<xsl:value-of select="$javaName"/>;
-        }
+        <xsl:for-each select="property">
+            <xsl:variable name="propertyType"><xsl:value-of select="@type"></xsl:value-of></xsl:variable>
+            <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
+            <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
+            /**
+            * field for <xsl:value-of select="$javaName"/>
+            <xsl:if test="@attribute">* This was an Attribute!</xsl:if>
+            <xsl:if test="@array">* This was an Array!</xsl:if>
+
+            */
+            private <xsl:value-of select="$propertyType"/> local<xsl:value-of select="$javaName"/>;
+
+            /**
+            * Auto generated getter method
+            * @return <xsl:value-of select="$propertyType"/>
+            */
+            public  <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of select="$javaName"/>(){
+            return local<xsl:value-of select="$javaName"/>;
+            }
 
-        /**
-         * Auto generated setter method
-         * @param param<xsl:value-of select="$javaName"/>
-         */
-        public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param<xsl:value-of select="$javaName"/>){
-             this.local<xsl:value-of select="$javaName"/>=param<xsl:value-of select="$javaName"/>;
-        }
-     </xsl:for-each>
+            /**
+            * Auto generated setter method
+            * @param param<xsl:value-of select="$javaName"/>
+            */
+            public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
+            <!--Add the validation code. For now we only add the validation code for arrays-->
+             <xsl:if test="@array">
+                 <xsl:if test="not(@unbound)">
+                     if (param.length &gt; <xsl:value-of select="@maxOccurs"></xsl:value-of>){
+                        throw new java.lang.RuntimeException();
+                     }
+                 </xsl:if>
+                 <xsl:if test="@minOccurs">
+                     if (param.length &lt; <xsl:value-of select="@minOccurs"></xsl:value-of>){
+                        throw new java.lang.RuntimeException();
+                     }
+                 </xsl:if>
+             </xsl:if>
+            this.local<xsl:value-of select="$javaName"/>=param;
+            }
+        </xsl:for-each>
 
         /**
-         * databinding method to get an XML representation of this object
-         * Note - this is not complete
-         */
+        * databinding method to get an XML representation of this object
+        * Note - this is not complete
+        */
         public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName){
 
-          Object[] elementList = new Object[]{
-          <xsl:for-each select="property[not(@attribute)]">
-           <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
-           <xsl:if test="position()>1">,</xsl:if>
-              <xsl:choose>
-                  <xsl:when test="@ours">
-                      new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),local<xsl:value-of select="@javaname"/>
-                  </xsl:when>
-                  <xsl:when test="@any">
-                      null,local<xsl:value-of select="@javaname"/>
-                  </xsl:when>
-                  <xsl:otherwise>
-                       "<xsl:value-of select="$propertyName"/>",org.apache.axis2.databinding.schema.util.ConverterUtil.convertToString(local<xsl:value-of select="@javaname"/>)
-                  </xsl:otherwise>
-              </xsl:choose>
-          </xsl:for-each>};
+        // Object[] elementList = new Object[]{
+        <xsl:for-each select="property[not(@attribute)]">
+            <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+            //<xsl:if test="position()>1">,</xsl:if>
+            <xsl:choose>
+                <xsl:when test="@ours">
+                    //           new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),local<xsl:value-of select="@javaname"/>
+                </xsl:when>
+                <xsl:when test="@any">
+                    //          null,local<xsl:value-of select="@javaname"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    //            "<xsl:value-of select="$propertyName"/>",org.apache.axis2.databinding.schema.util.ConverterUtil.convertToString(local<xsl:value-of select="@javaname"/>)
+                </xsl:otherwise>
+            </xsl:choose>
+            // </xsl:for-each>};
 
-         Object[] attribList = new Object[]{
+        // Object[] attribList = new Object[]{
         <xsl:for-each select="property[@attribute]">
-           <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
-           <xsl:if test="position()>1">,</xsl:if>
-           "<xsl:value-of select="$propertyName"/>",org.apache.axis2.databinding.schema.util.ConverterUtil.convertToString(local<xsl:value-of select="@javaname"/>)
-          </xsl:for-each>};
+            <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+            //  <xsl:if test="position()>1">,</xsl:if>
+            //  "<xsl:value-of select="$propertyName"/>",org.apache.axis2.databinding.schema.util.ConverterUtil.convertToString(local<xsl:value-of select="@javaname"/>)
+            //  </xsl:for-each>
+        // };
 
-         return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList, attribList);
+        //  return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList, attribList);
 
+        return null;
         }
 
         /**
-         * static method to create the object
-         * Note -  This is not complete
-         */
+        * static method to create the object
+        * Note -  This is not complete
+        */
         public static <xsl:value-of select="$name"/> parse(javax.xml.stream.XMLStreamReader reader){
         <xsl:value-of select="$name"/> object = new <xsl:value-of select="$name"/>();
         try {
-            int event = reader.getEventType();
-            int count = 0;
-            int argumentCount = <xsl:value-of select="count(property)"/> ;
-            boolean done =false;
-            //event better be a START_ELEMENT. if not we should go up to the start element here
-            while (!reader.isStartElement()){
-                event = reader.next();
+        int event = reader.getEventType();
+        int count = 0;
+        int argumentCount = <xsl:value-of select="count(property)"/> ;
+        boolean done =false;
+        //event better be a START_ELEMENT. if not we should go up to the start element here
+        while (!reader.isStartElement()){
+        event = reader.next();
+        }
+
+        while(!done){
+        if (javax.xml.stream.XMLStreamConstants.START_ELEMENT==event){
+        <xsl:for-each select="property">
+            <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+            <xsl:variable name="propertyType"><xsl:value-of select="@type"/></xsl:variable>
+            <xsl:variable name="shortTypeName"><xsl:value-of select="@shorttypename"/></xsl:variable>
+            <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
+
+            if ("<xsl:value-of select="$propertyName"/>".equals(reader.getLocalName())){
+            <xsl:choose>
+                <xsl:when test="@array">
+                    //do nothing yet for the array
+                </xsl:when>
+                <xsl:when test="@ours">
+                    object.set<xsl:value-of select="$javaName"/>(
+                    <xsl:value-of select="$propertyType"/>.parse(reader));
+                </xsl:when>
+                <xsl:when test="@any">
+                    //do nothing yet!!!!
+                </xsl:when>
+                <xsl:otherwise>
+                    String content = reader.getElementText();
+                    object.set<xsl:value-of select="$javaName"/>(
+                    org.apache.axis2.databinding.schema.util.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(content));
+                </xsl:otherwise>
+            </xsl:choose>
+            count++;
             }
+        </xsl:for-each>
+        event = reader.next();
+        }
 
-            while(!done){
-                if (javax.xml.stream.XMLStreamConstants.START_ELEMENT==event){
-           <xsl:for-each select="property">
-           <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
-           <xsl:variable name="propertyType"><xsl:value-of select="@type"/></xsl:variable>
-           <xsl:variable name="shortTypeName"><xsl:value-of select="@shorttypename"/></xsl:variable>
-          <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
-
-               if ("<xsl:value-of select="$propertyName"/>".equals(reader.getLocalName())){
-              <xsl:choose>
-                   <xsl:when test="@ours">
-                     object.set<xsl:value-of select="$javaName"/>(
-                          <xsl:value-of select="$propertyType"/>.parse(reader));
-                  </xsl:when>
-                  <xsl:when test="@any">
-                      //do nothing yet!!!!
-                  </xsl:when>
-                  <xsl:otherwise>
-                      String content = reader.getElementText();
-                      object.set<xsl:value-of select="$javaName"/>(
-                      org.apache.axis2.databinding.schema.util.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(content));
-                  </xsl:otherwise>
-                 </xsl:choose>
-                     count++;
-               }
-          </xsl:for-each>
-                event = reader.next();
-                }
-
-                if (argumentCount==count){
-                   done=true;
-                }
+        if (argumentCount==count){
+        done=true;
+        }
 
 
-            }
+        }
 
         } catch (javax.xml.stream.XMLStreamException e) {
-            e.printStackTrace();
+        e.printStackTrace();
         }
 
         return object;
         }
 
-    }
+        }
     </xsl:template>
- </xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java?rev=326840&r1=326839&r2=326840&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java Wed Oct 19 23:36:16 2005
@@ -99,7 +99,7 @@
             //create the type mapper
             JavaTypeMapper mapper = new JavaTypeMapper();
             //get the processed element map and transfer it to the type mapper
-            Map processedMap = schemaCompiler.getProcessedElementmap();
+            Map processedMap = schemaCompiler.getProcessedElementMap();
             Iterator processedkeys = processedMap.keySet().iterator();
             QName qNameKey;
             while (processedkeys.hasNext()) {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/ADBSupporterTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/ADBSupporterTemplate.xsl?rev=326840&r1=326839&r2=326840&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/ADBSupporterTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/ADBSupporterTemplate.xsl Wed Oct 19 23:36:16 2005
@@ -4,7 +4,7 @@
         package <xsl:value-of select="@package"/>;
 
         /**
-        *  Auto generated supporter class for XML beans by the Axis code generator
+        *  Auto generated supporter class for Axis2 own databinding by the Axis code generator
         */
 
         public class <xsl:value-of select="@name"/> extends org.apache.axis2.clientapi.AbstractCallbackSupporter{
@@ -19,25 +19,32 @@
 
         <xsl:for-each select="param">
             <xsl:if test="@type!=''">
-        public  static org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/> param){
-               if (param instanceof  org.apache.axis2.databinding.ADBBean){
-                    return param.getPullParser(adbBeanQName);
+                public  static org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/> param){
+                    if (param instanceof  org.apache.axis2.databinding.ADBBean){
+                        org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder = new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder
+                            (org.apache.axis2.om.OMAbstractFactory.getOMFactory(), param.getPullParser(null)); //todo need to change this
+                        return builder.getDocumentElement();
+                    }else{
+                        //handle the other types of beans here. Perhaps the reflective builder is
+                        //a good choice here
+                    }
+                    return null;
                 }
-               return documentElement;
-        }
             </xsl:if>
         </xsl:for-each>
 
-        public static org.apache.xmlbeans.XmlObject fromOM(org.apache.axis2.om.OMElement param,
-        java.lang.Class type){
+        public static java.lang.Object fromOM(org.apache.axis2.om.OMElement param,
+                java.lang.Class type){
         try{
-        <xsl:for-each select="param">
-            <xsl:if test="@type!=''">
-                if (<xsl:value-of select="@type"/>.class.equals(type)){
+            <xsl:for-each select="param">
+                <xsl:if test="@type!=''">
+                    if (<xsl:value-of select="@type"/>.class.equals(type)){
+                       if (org.apache.axis2.databinding.ADBBean.class.isAssignableFrom(type)){
 
-                }
-            </xsl:if>
-        </xsl:for-each>
+                       }
+                    }
+                </xsl:if>
+            </xsl:for-each>
         }catch(java.lang.Exception e){
             throw new RuntimeException("Data binding error",e);
         }
@@ -51,12 +58,12 @@
         <xsl:for-each select="param">
             <xsl:if test="@type!=''">
                 if (<xsl:value-of select="@type"/>.class.equals(type)){
-                <xsl:value-of select="@type"/> emptyObject= new <xsl:value-of select="@type"/>;
-                ////////////////////////////////////////////////
-                // TODO
-                // Fill in the empty object with necessaey values. Empty XMLBeans objects do not generate proper events
-                ////////////////////////////////////////////////
-                return emptyObject;
+                    <xsl:value-of select="@type"/> emptyObject= new <xsl:value-of select="@type"/>;
+                    ////////////////////////////////////////////////
+                    // TODO
+                    // Fill in the empty object with necessaey values. Empty XMLBeans objects do not generate proper events
+                    ////////////////////////////////////////////////
+                    return emptyObject;
                 }
             </xsl:if>
         </xsl:for-each>

Added: webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd?rev=326840&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd (added)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/anonymous_complexType.xsd Wed Oct 19 23:36:16 2005
@@ -0,0 +1,16 @@
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+        xmlns:tns="http://soapinterop.org/types"
+        targetNamespace="http://soapinterop.org/types">
+    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
+
+    <element name="tempElt">
+        <complexType>
+            <sequence>
+                <element name="varString" type="xsd:string"/>
+                <element name="varInt" type="xsd:int"/>
+                <element name="varFloat" type="xsd:float"/>
+            </sequence>
+        </complexType>
+    </element>
+</schema>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/complex_all.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/complex_all.xsd?rev=326840&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/complex_all.xsd (added)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/xsd/complex_all.xsd Wed Oct 19 23:36:16 2005
@@ -0,0 +1,75 @@
+<s:schema elementFormDefault="qualified" targetNamespace="http://www.strikeiron.com" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.strikeiron.com">
+      <s:element name="GetQuotes">
+        <s:complexType>
+          <s:sequence>
+            <s:element minOccurs="0" maxOccurs="1" name="TickerSymbolList" type="s:string" />
+          </s:sequence>
+        </s:complexType>
+
+      </s:element>
+      <s:element name="GetQuotesResponse">
+        <s:complexType>
+          <s:sequence>
+            <s:element minOccurs="0" maxOccurs="1" name="GetQuotesResult" type="s0:ArrayOfRealQuote" />
+          </s:sequence>
+        </s:complexType>
+      </s:element>
+      <s:complexType name="ArrayOfRealQuote">
+
+        <s:sequence>
+          <s:element minOccurs="0" maxOccurs="unbounded" name="RealQuote" nillable="true" type="s0:RealQuote" />
+        </s:sequence>
+      </s:complexType>
+      <s:complexType name="RealQuote">
+        <s:sequence>
+          <s:element minOccurs="0" maxOccurs="1" name="Symbol" type="s:string" />
+          <s:element minOccurs="0" maxOccurs="1" name="CUSIP" type="s:string" />
+          <s:element minOccurs="0" maxOccurs="1" name="CIK" type="s:string" />
+          <s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
+          <s:element minOccurs="0" maxOccurs="1" name="Date" type="s:string" />
+          <s:element minOccurs="0" maxOccurs="1" name="Time" type="s:string" />
+          <s:element minOccurs="1" maxOccurs="1" name="Last" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="Quantity" type="s:int" />
+          <s:element minOccurs="1" maxOccurs="1" name="ChangeFromPrevious" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="PercentChangeFromPrevious" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="Open" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="ChangeFromOpen" type="s:double" />
+
+          <s:element minOccurs="1" maxOccurs="1" name="PercentChangeFromOpen" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="Bid" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="Ask" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="Spread" type="s:double" />
+          <s:element minOccurs="1" maxOccurs="1" name="BidQuantity" type="s:int" />
+          <s:element minOccurs="1" maxOccurs="1" name="AskQuantity" type="s:int" />
+          <s:element minOccurs="1" maxOccurs="1" name="Volume" type="s:int" />
+          <s:element minOccurs="1" maxOccurs="1" name="ECNVolume" type="s:int" />
+          <s:element minOccurs="1" maxOccurs="1" name="Highest" type="s:double" />
+
+          <s:element minOccurs="1" maxOccurs="1" name="Lowest" type="s:double" />
+          <s:element minOccurs="0" maxOccurs="1" name="Rank" type="s:string" />
+        </s:sequence>
+      </s:complexType>
+      <s:element name="ResponseInfo" type="s0:ResponseInfo" />
+      <s:complexType name="ResponseInfo">
+        <s:sequence>
+          <s:element minOccurs="1" maxOccurs="1" name="ResponseCode" type="s:int" />
+          <s:element minOccurs="0" maxOccurs="1" name="Response" type="s:string" />
+
+        </s:sequence>
+      </s:complexType>
+      <s:element name="GetOneQuote">
+        <s:complexType>
+          <s:sequence>
+            <s:element minOccurs="0" maxOccurs="1" name="TickerSymbol" type="s:string" />
+          </s:sequence>
+        </s:complexType>
+      </s:element>
+
+      <s:element name="GetOneQuoteResponse">
+        <s:complexType>
+          <s:sequence>
+            <s:element minOccurs="0" maxOccurs="1" name="GetOneQuoteResult" type="s0:RealQuote" />
+          </s:sequence>
+        </s:complexType>
+      </s:element>
+    </s:schema>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java?rev=326840&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/AnonymousComplexTypeTest.java Wed Oct 19 23:36:16 2005
@@ -0,0 +1,23 @@
+package org.apache.axis2.databinding.schema;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class AnonymousComplexTypeTest extends AbstractSchemaCompilerTester{
+    protected void setUp() throws Exception {
+        this.fileName = "test-resources/xsd/anonymous_complexType.xsd";
+        super.setUp();
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java?rev=326840&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/schema/ComplexAllTest.java Wed Oct 19 23:36:16 2005
@@ -0,0 +1,25 @@
+package org.apache.axis2.databinding.schema;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ComplexAllTest extends AbstractSchemaCompilerTester{
+     protected void setUp() throws Exception {
+         this.fileName = "test-resources/xsd/complex_all.xsd";
+        super.setUp();
+    }
+
+
+}