You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ra...@apache.org on 2005/05/11 02:21:11 UTC

svn commit: r169544 - /xmlbeans/branches/1.x/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java

Author: radup
Date: Tue May 10 17:21:10 2005
New Revision: 169544

URL: http://svn.apache.org/viewcvs?rev=169544&view=rev
Log:
Port part of revision 110792 into the V1 branch. Contributed by Tracey Thomas.

Modified:
    xmlbeans/branches/1.x/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java

Modified: xmlbeans/branches/1.x/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
URL: http://svn.apache.org/viewcvs/xmlbeans/branches/1.x/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java?rev=169544&r1=169543&r2=169544&view=diff
==============================================================================
--- xmlbeans/branches/1.x/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java (original)
+++ xmlbeans/branches/1.x/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java Tue May 10 17:21:10 2005
@@ -21,6 +21,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 
 import javax.xml.namespace.QName;
 import org.apache.xmlbeans.impl.common.NameUtil;
@@ -286,7 +287,7 @@
         }
         else
         {
-            SchemaProperty[] props = sType.getDerivedProperties();
+            SchemaProperty[] props = getDerivedProperties(sType);
             for (int i = 0; i < props.length; i++)
             {
                 SchemaProperty prop = props[i];
@@ -2160,7 +2161,8 @@
                 // complex content type implementations derive from base type impls
                 // so derived property impls can be reused
                 
-                properties = sType.getDerivedProperties();
+                properties = getDerivedProperties(sType);
+                
             }
             
             Map qNameMap = printStaticFields(properties);
@@ -2214,6 +2216,31 @@
         printNestedTypeImpls(sType, system);
 
         endBlock();
+    }
+
+    private SchemaProperty[] getDerivedProperties(SchemaType sType) {
+        // We have to see if this is redefined, because if it is we have
+        // to include all properties associated to its supertypes
+        QName name = sType.getName();
+        if (name != null && name.equals(sType.getBaseType().getName())) {
+            SchemaType sType2 = sType.getBaseType();
+            // Walk all the redefined types and record any properties
+            // not present in sType, because the redefined types do not
+            // have a generated class to represent them
+            SchemaProperty[] props = sType.getDerivedProperties();
+            Map propsByName = new LinkedHashMap();
+            for (int i = 0; i < props.length; i++)
+                propsByName.put(props[i].getName(), props[i]);
+            while (sType2 != null && name.equals(sType2.getName())) {
+                props = sType2.getDerivedProperties();
+                for (int i = 0; i < props.length; i++)
+                    if (!propsByName.containsKey(props[i].getName()))
+                        propsByName.put(props[i].getName(), props[i]);
+                sType2 = sType2.getBaseType();
+            }
+            return (SchemaProperty[]) propsByName.values().toArray(new SchemaProperty[0]);
+        } else
+            return sType.getDerivedProperties();
     }
 
     private void printExtensionImplMethods(SchemaType sType) throws IOException



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org