Author: bimargulies
Date: Fri Mar  6 04:07:39 2009
New Revision: 750763

URL: http://svn.apache.org/viewvc?rev=750763&view=rev
Log:
Aegis wasn't always xs:import-ing array types across namespaces. It also was 
never setting maxOccurs into the schema,
and it was setting minOccurs wrong a fair part of the time.

Modified:
    
cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
    
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java

Modified: 
cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java?rev=750763&r1=750762&r2=750763&view=diff
==============================================================================
--- 
cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
 (original)
+++ 
cxf/trunk/common/common/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
 Fri Mar  6 04:07:39 2009
@@ -201,7 +201,7 @@
      * @param namespaceUri
      */
     public static void addImportIfNeeded(XmlSchema schema, String 
namespaceUri) {
-        // no need to import nothing or the XSD schema.
+        // no need to import nothing or the XSD schema, or the schema we are 
fixing.
         if ("".equals(namespaceUri) 
             || XmlSchemaConstants.XSD_NAMESPACE_URI.equals(namespaceUri)
             || schema.getTargetNamespace().equals(namespaceUri)) {

Modified: 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=750763&r1=750762&r2=750763&view=diff
==============================================================================
--- 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
 (original)
+++ 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
 Fri Mar  6 04:07:39 2009
@@ -436,19 +436,36 @@
         return type;
     }
 
-    private void writeTypeReference(QName name, XmlSchemaElement element, Type 
type) {
+    private void writeTypeReference(QName name, XmlSchemaElement element, Type 
type, 
+                                    XmlSchema schemaRoot) {
         if (type.isAbstract()) {
             element.setName(name.getLocalPart());
             element.setSchemaTypeName(type.getSchemaType());
+            XmlSchemaUtils.addImportIfNeeded(schemaRoot, 
type.getSchemaType().getNamespaceURI());
 
-            int minOccurs = getTypeInfo().getMinOccurs(name);
+            /*
+             * This seems to bespeak some sort of confusion. The problem is 
that
+             * no one ever implemented getMinOccurs(name) to even look at the 
per-element data.
+             */
+            long minOccurs = -1;
+            long maxOccurs = -1;
+            if (type instanceof ArrayType) {
+                ArrayType arrayType = (ArrayType) type;
+                minOccurs = arrayType.getMinOccurs();
+                maxOccurs = arrayType.getMaxOccurs();
+            } else {
+                minOccurs = getTypeInfo().getMinOccurs(name);
+            }
             /*
              * Old code had ridiculous '!=0' here, which cannot have been 
right.
              */
             if (minOccurs != -1) {
                 element.setMinOccurs(minOccurs);
             }
-
+            if (maxOccurs != -1) {
+                element.setMaxOccurs(maxOccurs);
+            }
+            
             element.setNillable(getTypeInfo().isNillable(name));
         } else {
             element.setRefName(type.getSchemaType());
@@ -703,7 +720,7 @@
                 XmlSchemaUtils.addImportIfNeeded(root, 
AbstractTypeCreator.HTTP_CXF_APACHE_ORG_ARRAYS);
             }
 
-            writeTypeReference(name, element, type);
+            writeTypeReference(name, element, type, root);
             needXmime |= type.usesXmime();
             needUtilityTypes |= type.usesUtilityTypes();
         }


Reply via email to