You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/12/17 22:16:05 UTC

svn commit: r1818516 [2/5] - in /axis/axis2/java/core/branches/AXIS2-4091: ./ modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/ modules/adb-codegen/src/org/apache/axis2/schema/template/ modules/adb-codegen/test/org/apache/axis2/sche...

Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=1818516&r1=1818515&r2=1818516&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Sun Dec 17 22:16:04 2017
@@ -35,7 +35,9 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaAnyAttribute;
 import org.apache.ws.commons.schema.XmlSchemaAttribute;
 import org.apache.ws.commons.schema.XmlSchemaAttributeGroup;
+import org.apache.ws.commons.schema.XmlSchemaAttributeGroupMember;
 import org.apache.ws.commons.schema.XmlSchemaAttributeGroupRef;
+import org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef;
 import org.apache.ws.commons.schema.XmlSchemaChoice;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaComplexContent;
@@ -47,8 +49,9 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
 import org.apache.ws.commons.schema.XmlSchemaExternal;
+import org.apache.ws.commons.schema.XmlSchemaFacet;
 import org.apache.ws.commons.schema.XmlSchemaGroup;
-import org.apache.ws.commons.schema.XmlSchemaGroupBase;
+import org.apache.ws.commons.schema.XmlSchemaGroupParticle;
 import org.apache.ws.commons.schema.XmlSchemaGroupRef;
 import org.apache.ws.commons.schema.XmlSchemaImport;
 import org.apache.ws.commons.schema.XmlSchemaInclude;
@@ -60,11 +63,10 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaMinInclusiveFacet;
 import org.apache.ws.commons.schema.XmlSchemaMinLengthFacet;
 import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
-import org.apache.ws.commons.schema.XmlSchemaObjectTable;
 import org.apache.ws.commons.schema.XmlSchemaParticle;
 import org.apache.ws.commons.schema.XmlSchemaPatternFacet;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
 import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
 import org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension;
 import org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction;
@@ -81,7 +83,6 @@ import javax.xml.namespace.QName;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -102,21 +103,21 @@ public class SchemaCompiler {
     private static final Log log = LogFactory.getLog(SchemaCompiler.class);
 
     private CompilerOptions options;
-    private HashMap<QName,String> processedTypemap;
+    private HashMap<QName, String> processedTypemap;
     // have to keep a seperate group type map since same
     // name can be used to group and complextype
-    private HashMap<QName,String> processedGroupTypeMap;
+    private HashMap<QName, String> processedGroupTypeMap;
 
     //the list of processedElements for the outer elements
-    private HashMap<QName,String> processedElementMap;
+    private HashMap<QName, String> processedElementMap;
 
-    private HashMap<XmlSchemaElement,BeanWriterMetaInfoHolder> processedAnonymousComplexTypesMap;
+    private HashMap<XmlSchemaElement, BeanWriterMetaInfoHolder> processedAnonymousComplexTypesMap;
 
     //we need this map to keep the referenced elements. these elements need to be kept seperate
     //to avoid conflicts
-    private HashMap<QName,String> processedElementRefMap;
-    private HashMap<QName,String> simpleTypesMap;
-    private HashMap<QName,QName> changedTypeMap;
+    private HashMap<QName, String> processedElementRefMap;
+    private HashMap<QName, String> simpleTypesMap;
+    private HashMap<QName, QName> changedTypeMap;
 
     private HashSet<XmlSchemaSimpleType> changedSimpleTypeSet;
     private HashSet<XmlSchemaComplexType> changedComplexTypeSet;
@@ -125,7 +126,7 @@ public class SchemaCompiler {
     // this map is necessary to retain the metainformation of types. The reason why these
     // meta info 'bags' would be useful later is to cater for the extensions and restrictions
     // of types
-    private HashMap<QName,BeanWriterMetaInfoHolder> processedTypeMetaInfoMap;
+    private HashMap<QName, BeanWriterMetaInfoHolder> processedTypeMetaInfoMap;
 
     //
     private ArrayList<QName> processedElementList;
@@ -135,19 +136,19 @@ public class SchemaCompiler {
     private List<QName> nillableElementList;
     // writee reference
     private BeanWriter writer = null;
-    private Map<QName,String> baseSchemaTypeMap = null;
+    private Map<QName, String> baseSchemaTypeMap = null;
 
     //a map for keeping the already loaded schemas
     //the key is the targetnamespace and the value is the schema object
-    private Map<String,XmlSchema> loadedSchemaMap = new HashMap<String,XmlSchema>();
+    private Map<String, XmlSchema> loadedSchemaMap = new HashMap<String, XmlSchema>();
 
     // A map keeping the available schemas
     //the key is the targetnamespace and the value is the schema object
     //this map will be populated when multiple schemas
     //are fed to the schema compiler!
-    private Map<String,XmlSchema> availableSchemaMap = new HashMap<String,XmlSchema>();
+    private Map<String, XmlSchema> availableSchemaMap = new HashMap<String, XmlSchema>();
 
-    private Map<String,String> loadedSourceURI = new HashMap<String,String>();
+    private Map<String, String> loadedSourceURI = new HashMap<String, String>();
 
     // a list of externally identified QNames to be processed. This becomes
     // useful when  only a list of external elements need to be processed
@@ -164,7 +165,7 @@ public class SchemaCompiler {
      *         includes the Qname of the element as the key and a
      *         String representing the fully qualified class name
      */
-    public HashMap<QName,String> getProcessedElementMap() {
+    public HashMap<QName, String> getProcessedElementMap() {
         return processedElementMap;
     }
 
@@ -194,26 +195,26 @@ public class SchemaCompiler {
 
         Map<String, String> nsp2PackageMap = this.options.getNs2PackageMap();
 
-        if (nsp2PackageMap == null){
+        if (nsp2PackageMap == null) {
             nsp2PackageMap = new HashMap();
             this.options.setNs2PackageMap(nsp2PackageMap);
         }
 
-        if (!nsp2PackageMap.containsKey("")){
-            nsp2PackageMap.put("","axis2.apache.org");
+        if (!nsp2PackageMap.containsKey("")) {
+            nsp2PackageMap.put("", "axis2.apache.org");
         }
 
         //instantiate the maps
-        processedTypemap = new HashMap<QName,String>();
-        processedGroupTypeMap = new HashMap<QName,String>();
+        processedTypemap = new HashMap<QName, String>();
+        processedGroupTypeMap = new HashMap<QName, String>();
 
-        processedElementMap = new HashMap<QName,String>();
-        simpleTypesMap = new HashMap<QName,String>();
+        processedElementMap = new HashMap<QName, String>();
+        simpleTypesMap = new HashMap<QName, String>();
         processedElementList = new ArrayList<QName>();
-        processedAnonymousComplexTypesMap = new HashMap<XmlSchemaElement,BeanWriterMetaInfoHolder>();
-        changedTypeMap = new HashMap<QName,QName>();
-        processedTypeMetaInfoMap = new HashMap<QName,BeanWriterMetaInfoHolder>();
-        processedElementRefMap = new HashMap<QName,String>();
+        processedAnonymousComplexTypesMap = new HashMap<XmlSchemaElement, BeanWriterMetaInfoHolder>();
+        changedTypeMap = new HashMap<QName, QName>();
+        processedTypeMetaInfoMap = new HashMap<QName, BeanWriterMetaInfoHolder>();
+        processedElementRefMap = new HashMap<QName, String>();
         nillableElementList = new ArrayList<QName>();
 
         changedComplexTypeSet = new HashSet<XmlSchemaComplexType>();
@@ -265,14 +266,15 @@ public class SchemaCompiler {
                 //mapper namespace
                 for (XmlSchema schema : schemalist) {
                     nsp = schema.getTargetNamespace();
-                    if ((nsp != null) && !nsp.equals("")){
+                    if ((nsp != null) && !nsp.equals("")) {
                         break;
                     }
                     XmlSchema[] schemas = SchemaUtil.getAllSchemas(schema);
                     for (int j = 0; schemas != null && j < schemas.length; j++) {
                         nsp = schemas[j].getTargetNamespace();
-                        if (nsp != null)
+                        if (nsp != null) {
                             break;
+                        }
                     }
                 }
                 if (nsp == null) {
@@ -281,10 +283,11 @@ public class SchemaCompiler {
 
                 // if this name space exists in the ns2p list then we use it.
                 if ((options.getNs2PackageMap() != null)
-                        && (options.getNs2PackageMap().containsKey(nsp))) {
+                    && (options.getNs2PackageMap().containsKey(nsp))) {
                     writer.registerExtensionMapperPackageName(options.getNs2PackageMap().get(nsp));
                 } else {
-                    writer.registerExtensionMapperPackageName(nsp == null ? null : URLProcessor.makePackageName(nsp));
+                    writer.registerExtensionMapperPackageName(nsp == null ? null :
+                                                              URLProcessor.makePackageName(nsp));
                 }
             }
             // second round - call the schema compiler one by one
@@ -319,7 +322,8 @@ public class SchemaCompiler {
      * @param isPartofGroup
      * @throws SchemaCompilationException
      */
-    private void compile(XmlSchema schema, boolean isPartofGroup) throws SchemaCompilationException {
+    private void compile(XmlSchema schema, boolean isPartofGroup)
+            throws SchemaCompilationException {
 
         // some documents explicitly imports the schema of built in types. We don't actually need to compile
         // the built-in types. So check the target namespace here and ignore it.
@@ -337,7 +341,7 @@ public class SchemaCompiler {
                 }
                 // if this name space exists in the ns2p list then we use it.
                 if ((options.getNs2PackageMap() != null)
-                        && (options.getNs2PackageMap().containsKey(ns))) {
+                    && (options.getNs2PackageMap().containsKey(ns))) {
                     writer.registerExtensionMapperPackageName(options.getNs2PackageMap().get(ns));
                 } else {
                     writer.registerExtensionMapperPackageName(URLProcessor.makePackageName(ns));
@@ -355,7 +359,7 @@ public class SchemaCompiler {
             // but when importing import namesapce location is given as "".
             // this causese a problem in finding reference elements. see AXIS2-3029
             // kept the null entry as well to safe gaurd any thing which acess using null
-            if (schema.getTargetNamespace() == null){
+            if (schema.getTargetNamespace() == null) {
                 loadedSchemaMap.put("", schema);
             }
         }
@@ -370,74 +374,66 @@ public class SchemaCompiler {
             loadedSourceURI.put(key, key);
         }
 
-        XmlSchemaObjectCollection includes = schema.getIncludes();
-        if (includes != null) {
-            Iterator tempIterator = includes.getIterator();
-            while (tempIterator.hasNext()) {
-                Object o = tempIterator.next();
-                if (o instanceof XmlSchemaImport) {
-                    XmlSchemaImport schemaImport = (XmlSchemaImport)o;
-                    XmlSchema schema1 = schemaImport.getSchema();
-                    if (schema1 != null) {
-                        compile(schema1, isPartofGroup);
-                    } else if (schemaImport.getNamespace().equals(Constants.NS_URI_XML)) {
-                        // AXIS2-3229: some Web services (e.g. MS Exchange) assume that
-                        // http://www.w3.org/XML/1998/namespace is a known namespace and that
-                        // no schemaLocation is required when importing it. Load a local copy of
-                        // the schema in that case.
-                        schema1 = new XmlSchemaCollection().read(new InputSource(
-                                SchemaCompiler.class.getResource("namespace.xsd").toExternalForm()), null);
-                        schemaImport.setSchema(schema1);
-                        compile(schema1, isPartofGroup);
-                    } else if (!schemaImport.getNamespace().equals(Constants.URI_2001_SCHEMA_XSD)) {
-                        // Give the user a hint why the schema compilation fails...
-                        log.warn("No schemaLocation for import of " + schemaImport.getNamespace() + "; compilation may fail");
-                    }
-                }
-                if (o instanceof XmlSchemaInclude) {
-                    XmlSchema schema1 = ((XmlSchemaInclude) o).getSchema();
-                    if (schema1 != null){
-                        if (schema1.getTargetNamespace() == null){
-                            // the target namespace of an included shchema should be same
-                            // as the parent schema however if the schema uses the chemalon pattern
-                            // target namespace can be null. so set it here.
-                            // http://www.xfront.com/ZeroOneOrManyNamespaces.html#mixed
-                            schema1.setTargetNamespace(schema.getTargetNamespace());
-                        }
-                        compile(schema1, isPartofGroup);
-                    }
+        for (XmlSchemaObject object : schema.getExternals()) {
 
+            if (object instanceof XmlSchemaImport) {
+                XmlSchemaImport schemaImport = (XmlSchemaImport) object;
+                XmlSchema schema1 = schemaImport.getSchema();
+                if (schema1 != null) {
+                    compile(schema1, isPartofGroup);
+                } else if (schemaImport.getNamespace().equals(Constants.NS_URI_XML)) {
+                    // AXIS2-3229: some Web services (e.g. MS Exchange) assume that
+                    // http://www.w3.org/XML/1998/namespace is a known namespace and that
+                    // no schemaLocation is required when importing it. Load a local copy of
+                    // the schema in that case.
+                    schema1 = new XmlSchemaCollection().read(new InputSource(
+                            SchemaCompiler.class.getResource("namespace.xsd").toExternalForm()));
+                    schemaImport.setSchema(schema1);
+                    compile(schema1, isPartofGroup);
+                } else if (!schemaImport.getNamespace().equals(Constants.URI_2001_SCHEMA_XSD)) {
+                    // Give the user a hint why the schema compilation fails...
+                    log.warn("No schemaLocation for import of " + schemaImport.getNamespace() +
+                             "; compilation may fail");
+                }
+            }
+            if (object instanceof XmlSchemaInclude) {
+                XmlSchema schema1 = ((XmlSchemaInclude) object).getSchema();
+                if (schema1 != null) {
+                    if (schema1.getTargetNamespace() == null) {
+                        // the target namespace of an included shchema should be same
+                        // as the parent schema however if the schema uses the chemalon pattern
+                        // target namespace can be null. so set it here.
+                        // http://www.xfront.com/ZeroOneOrManyNamespaces.html#mixed
+                        schema1.setTargetNamespace(schema.getTargetNamespace());
+                    }
+                    compile(schema1, isPartofGroup);
                 }
+
             }
+
         }
 
         //select all the elements. We generate the code for types
         //only if the elements refer them!!! regardless of the fact that
         //we have a list of elementnames, we'll need to process all the elements
-        XmlSchemaObjectTable elements = schema.getElements();
-        Iterator xmlSchemaElement1Iterator = elements.getValues();
-        while (xmlSchemaElement1Iterator.hasNext()) {
+        for (XmlSchemaElement element : schema.getElements().values()) {
             //this is the set of outer elements so we need to generate classes
             //The outermost elements do not contain occurence counts (!) so we do not need
             //to check for arraytypes
-            processElement((XmlSchemaElement) xmlSchemaElement1Iterator.next(), schema);
+            processElement(element, schema);
         }
 
-        Iterator xmlSchemaElement2Iterator = elements.getValues();
-
         // re-iterate through the elements and write them one by one
         // if the mode is unpack this process will not really write the
         // classes but will accumilate the models for a final single shot
         // write
-        while (xmlSchemaElement2Iterator.hasNext()) {
+        for (XmlSchemaElement element : schema.getElements().values()) {
             //this is the set of outer elements so we need to generate classes
-            writeElement((XmlSchemaElement) xmlSchemaElement2Iterator.next());
+            writeElement(element);
         }
 
         if (options.isGenerateAll()) {
-            Iterator xmlSchemaTypes2Iterator = schema.getSchemaTypes().getValues();
-            while (xmlSchemaTypes2Iterator.hasNext()) {
-                XmlSchemaType schemaType = (XmlSchemaType) xmlSchemaTypes2Iterator.next();
+            for (XmlSchemaType schemaType : schema.getSchemaTypes().values()) {
                 if (this.isAlreadyProcessed(schemaType.getQName())) {
                     continue;
                 }
@@ -450,8 +446,8 @@ public class SchemaCompiler {
                 } else if (schemaType instanceof XmlSchemaSimpleType) {
                     //process simple type
                     processSimpleSchemaType((XmlSchemaSimpleType) schemaType,
-                            null,
-                            schema, null);
+                                            null,
+                                            schema, null);
                 }
             }
         }
@@ -471,8 +467,8 @@ public class SchemaCompiler {
     private void finalizeSchemaCompilation() throws SchemaCompilationException {
         //write the extension mapping class
         writer.writeExtensionMapper(
-                    processedTypeMetaInfoMap.values().toArray(
-                            new BeanWriterMetaInfoHolder[processedTypeMetaInfoMap.size()]));
+                processedTypeMetaInfoMap.values().toArray(
+                        new BeanWriterMetaInfoHolder[processedTypeMetaInfoMap.size()]));
 
 
         if (options.isWrapClasses()) {
@@ -534,31 +530,31 @@ public class SchemaCompiler {
             //this means the schema type actually returns a different QName
             if (changedTypeMap.containsKey(qName)) {
                 metainf.registerMapping(xsElt.getQName(),
-                        changedTypeMap.get(qName),
-                        className);
+                                        changedTypeMap.get(qName),
+                                        className);
             } else {
                 metainf.registerMapping(xsElt.getQName(),
-                        qName,
-                        className);
+                                        qName,
+                                        className);
             }
 
             // register the default value if present
-            if (xsElt.getDefaultValue() != null){
-                metainf.registerDefaultValue(xsElt.getQName(),xsElt.getDefaultValue());
+            if (xsElt.getDefaultValue() != null) {
+                metainf.registerDefaultValue(xsElt.getQName(), xsElt.getDefaultValue());
             }
 
             // register the fixed value if present
-            if (xsElt.getFixedValue() != null){
-                metainf.registerDefaultValue(xsElt.getQName(),xsElt.getFixedValue());
+            if (xsElt.getFixedValue() != null) {
+                metainf.registerDefaultValue(xsElt.getQName(), xsElt.getFixedValue());
                 metainf.setFixed(true);
             }
-            
+
             if (isBinary(xsElt)) {
                 metainf.addtStatus(xsElt.getQName(),
-                            SchemaConstants.BINARY_TYPE);
+                                   SchemaConstants.BINARY_TYPE);
             }
 
-        } else if (xsElt.getRefName() != null) {
+        } else if (xsElt.getRef().getTargetQName() != null) {
             // Since top level elements would not have references
             // and we only write toplevel elements, this should
             // not be a problem , atleast should not occur in a legal schema
@@ -566,8 +562,8 @@ public class SchemaCompiler {
             QName qName = xsElt.getSchemaTypeName();
             String className = findClassName(qName, isArray(xsElt));
             metainf.registerMapping(xsElt.getQName(),
-                    qName,
-                    className);
+                                    qName,
+                                    className);
 
 
         } else if (schemaType != null) {  //the named type should have been handled already
@@ -582,9 +578,9 @@ public class SchemaCompiler {
             //this means we did not find any schema type associated with the particular element.
             log.warn(SchemaCompilerMessages.getMessage("schema.elementWithNoType", xsElt.getQName().toString()));
             metainf.registerMapping(xsElt.getQName(),
-                    null,
-                    writer.getDefaultClassName(),
-                    SchemaConstants.ANY_TYPE);
+                                    null,
+                                    writer.getDefaultClassName(),
+                                    SchemaConstants.ANY_TYPE);
         }
 
         if (nillableElementList.contains(xsElt.getQName())) {
@@ -606,7 +602,9 @@ public class SchemaCompiler {
      * @param parentSchema
      * @throws SchemaCompilationException
      */
-    private void processElement(XmlSchemaElement xsElt, Map<QName,String> innerElementMap, List<QName> localNillableList, XmlSchema parentSchema) throws SchemaCompilationException {
+    private void processElement(XmlSchemaElement xsElt, Map<QName, String> innerElementMap,
+                                List<QName> localNillableList, XmlSchema parentSchema)
+            throws SchemaCompilationException {
         processElement(xsElt, false, innerElementMap, localNillableList, parentSchema);
     }
 
@@ -617,7 +615,8 @@ public class SchemaCompiler {
      * @param parentSchema
      * @throws SchemaCompilationException
      */
-    private void processElement(XmlSchemaElement xsElt, XmlSchema parentSchema) throws SchemaCompilationException {
+    private void processElement(XmlSchemaElement xsElt, XmlSchema parentSchema)
+            throws SchemaCompilationException {
         processElement(xsElt, true, null, null, parentSchema);
     }
 
@@ -629,7 +628,9 @@ public class SchemaCompiler {
      *                inner elements
      * @throws SchemaCompilationException
      */
-    private void processElement(XmlSchemaElement xsElt, boolean isOuter, Map<QName,String> innerElementMap, List<QName> localNillableList, XmlSchema parentSchema) throws SchemaCompilationException {
+    private void processElement(XmlSchemaElement xsElt, boolean isOuter,
+                                Map<QName, String> innerElementMap, List<QName> localNillableList,
+                                XmlSchema parentSchema) throws SchemaCompilationException {
 
         //if the element is null, which usually happens when the qname is not
         //proper, throw an exceptions
@@ -638,7 +639,7 @@ public class SchemaCompiler {
                     SchemaCompilerMessages.getMessage("schema.elementNull"));
         }
 
-       
+
         //The processing element logic seems to be quite simple. Look at the relevant schema type
         //for each and every element and process that accordingly.
         //this means that any unused type definitions would not be generated!
@@ -659,17 +660,19 @@ public class SchemaCompiler {
                     // this element already has a name. Which means we can directly
                     // register it
                     String className = findClassName(schemaType.getQName(),
-                            isArray(xsElt));
+                                                     isArray(xsElt));
 
                     innerElementMap.put(xsElt.getQName(), className);
 
                     // always store the class name in the element meta Info itself
                     // this details only needed by the unwrappig to set the complex type
                     if (options.isUseWrapperClasses() && PrimitiveTypeFinder.isPrimitive(className)) {
-                          className = PrimitiveTypeWrapper.getWrapper(className);
+                        className = PrimitiveTypeWrapper.getWrapper(className);
                     }
-                    schemaType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, className);
-                    xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, className);
+                    schemaType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+                                           className);
+                    xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+                                      className);
 
                     if (baseSchemaTypeMap.containsValue(className)) {
                         schemaType.addMetaInfo(
@@ -687,17 +690,19 @@ public class SchemaCompiler {
                     if (schemaType instanceof XmlSchemaComplexType) {
                         //set a name
                         schemaType.setName(generatedTypeName.getLocalPart());
-                        changedComplexTypeSet.add((XmlSchemaComplexType)schemaType);
+                        changedComplexTypeSet.add((XmlSchemaComplexType) schemaType);
                         // Must do this up front to support recursive types
-                        String fullyQualifiedClassName = writer.makeFullyQualifiedClassName(schemaType.getQName());
+                        String fullyQualifiedClassName = writer.
+                                makeFullyQualifiedClassName(schemaType.getQName());
                         processedTypemap.put(schemaType.getQName(), fullyQualifiedClassName);
 
-                        BeanWriterMetaInfoHolder metaInfHolder = processedAnonymousComplexTypesMap.get(xsElt);
+                        BeanWriterMetaInfoHolder metaInfHolder =
+                                processedAnonymousComplexTypesMap.get(xsElt);
                         metaInfHolder.setOwnQname(schemaType.getQName());
                         metaInfHolder.setOwnClassName(fullyQualifiedClassName);
 
                         writeComplexType((XmlSchemaComplexType) schemaType,
-                                metaInfHolder);
+                                         metaInfHolder);
                         //remove the reference from the anon list since we named the type
                         processedAnonymousComplexTypesMap.remove(xsElt);
                         String className = findClassName(schemaType.getQName(), isArray(xsElt));
@@ -712,17 +717,19 @@ public class SchemaCompiler {
                     } else if (schemaType instanceof XmlSchemaSimpleType) {
                         //set a name
                         schemaType.setName(generatedTypeName.getLocalPart());
-                        changedSimpleTypeSet.add((XmlSchemaSimpleType)schemaType);
+                        changedSimpleTypeSet.add((XmlSchemaSimpleType) schemaType);
                         // Must do this up front to support recursive types
-                        String fullyQualifiedClassName = writer.makeFullyQualifiedClassName(schemaType.getQName());
+                        String fullyQualifiedClassName = writer.
+                                makeFullyQualifiedClassName(schemaType.getQName());
                         processedTypemap.put(schemaType.getQName(), fullyQualifiedClassName);
 
-                        BeanWriterMetaInfoHolder metaInfHolder = processedAnonymousComplexTypesMap.get(xsElt);
+                        BeanWriterMetaInfoHolder metaInfHolder =
+                                processedAnonymousComplexTypesMap.get(xsElt);
                         metaInfHolder.setOwnQname(schemaType.getQName());
                         metaInfHolder.setOwnClassName(fullyQualifiedClassName);
 
                         writeSimpleType((XmlSchemaSimpleType) schemaType,
-                                metaInfHolder);
+                                        metaInfHolder);
                         //remove the reference from the anon list since we named the type
                         processedAnonymousComplexTypesMap.remove(xsElt);
                         String className = findClassName(schemaType.getQName(), isArray(xsElt));
@@ -741,43 +748,55 @@ public class SchemaCompiler {
                 this.processedElementList.add(xsElt.getQName());
             }
             //referenced name
-        } else if (xsElt.getRefName() != null) {
+        } else if (xsElt.getRef().getTargetQName() != null) {
 
-            if (xsElt.getRefName().equals(SchemaConstants.XSD_SCHEMA)) {
+            if (xsElt.getRef().getTargetQName().equals(SchemaConstants.XSD_SCHEMA)) {
                 innerElementMap.put(xsElt.getQName(), writer.getDefaultClassName());
                 return;
             }
             //process the referenced type. It could be thought that the referenced element replaces this
             //element
-            XmlSchema resolvedSchema = getParentSchema(parentSchema,xsElt.getRefName(),COMPONENT_ELEMENT);
-            if (resolvedSchema == null){
-                throw new SchemaCompilationException("can not find the element " + xsElt.getRefName()
-                 + " from the parent schema " + parentSchema.getTargetNamespace());
+            XmlSchema resolvedSchema = getParentSchema(parentSchema,
+                                                       xsElt.getRef().getTargetQName(),
+                                                       COMPONENT_ELEMENT);
+            if (resolvedSchema == null) {
+                throw new SchemaCompilationException("can not find the element " +
+                                                     xsElt.getRef().getTargetQName()
+                                                     + " from the parent schema " +
+                                                     parentSchema.getTargetNamespace());
             }
-            XmlSchemaElement referencedElement = resolvedSchema.getElementByName(xsElt.getRefName());
+            XmlSchemaElement referencedElement = resolvedSchema.
+                    getElementByName(xsElt.getRef().getTargetQName());
             if (referencedElement == null) {
                 throw new SchemaCompilationException(
-                        SchemaCompilerMessages.getMessage("schema.referencedElementNotFound", xsElt.getRefName().toString()));
+                        SchemaCompilerMessages.
+                                getMessage("schema.referencedElementNotFound",
+                                           xsElt.getRef().getTargetQName().toString()));
             }
 
             // here what we want is to set the schema type name for the element
             if ((referencedElement.getSchemaType() != null)
-                    && (referencedElement.getSchemaType().getQName() != null)){
+                && (referencedElement.getSchemaType().getQName() != null)) {
 
                 // i.e this element refers to an complex type name
                 if (!this.processedElementRefMap.containsKey(referencedElement.getQName())) {
                     if (this.baseSchemaTypeMap.containsKey(referencedElement.getSchemaTypeName())) {
                         this.processedElementRefMap.put(referencedElement.getQName(),
-                                this.baseSchemaTypeMap.get(referencedElement.getSchemaTypeName()));
+                                                        this.baseSchemaTypeMap.
+                                                                get(referencedElement.
+                                                                        getSchemaTypeName()));
                     } else {
                         XmlSchema resolvedTypeSchema = getParentSchema(resolvedSchema,
-                                referencedElement.getSchemaTypeName(),
-                                COMPONENT_TYPE);
+                                                                       referencedElement.
+                                                                               getSchemaTypeName(),
+                                                                       COMPONENT_TYPE);
                         XmlSchemaType xmlSchemaType = resolvedTypeSchema.getTypeByName(
                                 referencedElement.getSchemaTypeName().getLocalPart());
                         processSchema(referencedElement, xmlSchemaType, resolvedTypeSchema, true);
                         this.processedElementRefMap.put(referencedElement.getQName(),
-                                this.processedTypemap.get(referencedElement.getSchemaTypeName()));
+                                                        this.processedTypemap.
+                                                                get(referencedElement.
+                                                                        getSchemaTypeName()));
                     }
                 }
                 String javaClassName;
@@ -785,29 +804,34 @@ public class SchemaCompiler {
                     // here we have to do nothing since we do not generate a name
                 } else {
                     javaClassName = this.processedTypemap.get(referencedElement.getSchemaTypeName());
-                    referencedElement.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                            javaClassName);
+                    referencedElement.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.
+                                                          CLASSNAME_KEY,
+                                                  javaClassName);
                     xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                            javaClassName);
+                                      javaClassName);
                 }
             } else if (referencedElement.getSchemaType() != null) {
                 if (!this.processedElementRefMap.containsKey(referencedElement.getQName())) {
 
-                    processSchema(referencedElement, referencedElement.getSchemaType(), resolvedSchema, true);
+                    processSchema(referencedElement, referencedElement.getSchemaType(),
+                                  resolvedSchema, true);
                     // if this is an anonomous complex type we have to set this
                     this.processedElementRefMap.put(referencedElement.getQName(),
-                            this.processedTypemap.get(referencedElement.getSchemaTypeName()));
+                                                    this.processedTypemap.get(referencedElement.
+                                                            getSchemaTypeName()));
 
                 }
-                
-                String javaClassName = this.processedTypemap.get(referencedElement.getSchemaTypeName());
+
+                String javaClassName = this.processedTypemap.
+                        get(referencedElement.getSchemaTypeName());
                 referencedElement.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                        javaClassName);
+                                              javaClassName);
                 xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                        javaClassName);
-            } else if (referencedElement.getSchemaTypeName() != null){
+                                  javaClassName);
+            } else if (referencedElement.getSchemaTypeName() != null) {
                 QName schemaTypeName = referencedElement.getSchemaTypeName();
-                XmlSchema newResolvedSchema = getParentSchema(resolvedSchema, schemaTypeName, COMPONENT_TYPE);
+                XmlSchema newResolvedSchema = getParentSchema(resolvedSchema, schemaTypeName,
+                                                              COMPONENT_TYPE);
                 XmlSchemaType xmlSchemaType = newResolvedSchema.getTypeByName(schemaTypeName);
                 if (xmlSchemaType != null) {
                     if (!this.processedElementRefMap.containsKey(referencedElement.getQName())) {
@@ -815,17 +839,20 @@ public class SchemaCompiler {
                         processSchema(referencedElement, xmlSchemaType, newResolvedSchema, false);
                         // if this is an anonomous complex type we have to set this
                         this.processedElementRefMap.put(referencedElement.getQName(),
-                                this.processedTypemap.get(schemaTypeName));
+                                                        this.processedTypemap.get(schemaTypeName));
 
                     }
 
-                    String javaClassName = this.processedTypemap.get(referencedElement.getSchemaTypeName());
-                    referencedElement.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                            javaClassName);
+                    String javaClassName = this.processedTypemap.get(referencedElement.
+                            getSchemaTypeName());
+                    referencedElement.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.
+                                                          CLASSNAME_KEY,
+                                                  javaClassName);
                     xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                            javaClassName);
+                                      javaClassName);
                 } else {
-                    throw new SchemaCompilationException(" Can not find the schema type with name " + schemaTypeName);
+                    throw new SchemaCompilationException(" Can not find the schema type with name " +
+                                                         schemaTypeName);
                 }
 
             }
@@ -836,10 +863,10 @@ public class SchemaCompiler {
             //this specifically happens with xsd:anyType.
             QName schemaTypeName = xsElt.getSchemaTypeName();
 
-            XmlSchema resolvedSchema = getParentSchema(parentSchema,schemaTypeName,COMPONENT_TYPE);
+            XmlSchema resolvedSchema = getParentSchema(parentSchema, schemaTypeName, COMPONENT_TYPE);
             XmlSchemaType typeByName = null;
-            if (resolvedSchema != null){
-               typeByName = resolvedSchema.getTypeByName(schemaTypeName);
+            if (resolvedSchema != null) {
+                typeByName = resolvedSchema.getTypeByName(schemaTypeName);
             }
 
             if (typeByName != null) {
@@ -851,7 +878,7 @@ public class SchemaCompiler {
                     innerElementMap.put(xsElt.getQName(), className);
                     // set the class name to be used in unwrapping
                     xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                                className);
+                                      className);
                 } else {
                     this.processedElementList.add(xsElt.getQName());
                 }
@@ -862,7 +889,7 @@ public class SchemaCompiler {
                     innerElementMap.put(xsElt.getQName(), className);
                     // set the class name to be used in unwrapping
                     xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                                className);
+                                      className);
                 } else {
                     this.processedElementList.add(xsElt.getQName());
                 }
@@ -888,10 +915,12 @@ public class SchemaCompiler {
      */
     private QName generateTypeQName(QName referenceEltQName, XmlSchema parentSchema) {
         QName generatedTypeName = new QName(referenceEltQName.getNamespaceURI(),
-                referenceEltQName.getLocalPart() + getNextTypeSuffix(referenceEltQName.getLocalPart()));
+                                            referenceEltQName.getLocalPart() +
+                                            getNextTypeSuffix(referenceEltQName.getLocalPart()));
         while (parentSchema.getTypeByName(generatedTypeName) != null) {
             generatedTypeName = new QName(referenceEltQName.getNamespaceURI(),
-                    referenceEltQName.getLocalPart() + getNextTypeSuffix(referenceEltQName.getLocalPart()));
+                                          referenceEltQName.getLocalPart() +
+                                          getNextTypeSuffix(referenceEltQName.getLocalPart()));
         }
         return generatedTypeName;
     }
@@ -903,9 +932,9 @@ public class SchemaCompiler {
      */
     private boolean isAlreadyProcessed(QName qName) {
         return processedTypemap.containsKey(qName) ||
-                simpleTypesMap.containsKey(qName) ||
-                baseSchemaTypeMap.containsKey(qName) ||
-                processedGroupTypeMap.containsKey(qName);
+               simpleTypesMap.containsKey(qName) ||
+               baseSchemaTypeMap.containsKey(qName) ||
+               processedGroupTypeMap.containsKey(qName);
     }
 
 
@@ -951,7 +980,8 @@ public class SchemaCompiler {
             className = baseSchemaTypeMap.get(qName);
         } else {
             if (isSOAP_ENC(qName.getNamespaceURI())) {
-                throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.soapencoding.error", qName.toString()));
+                throw new SchemaCompilationException(SchemaCompilerMessages.
+                        getMessage("schema.soapencoding.error", qName.toString()));
 
             }
             // We seem to have failed in finding a class name for the
@@ -960,7 +990,7 @@ public class SchemaCompiler {
             //property file
             className = writer.getDefaultClassName();
             log.warn(SchemaCompilerMessages
-                    .getMessage("schema.typeMissing", qName.toString()));
+                             .getMessage("schema.typeMissing", qName.toString()));
         }
 
         if (isArray) {
@@ -981,8 +1011,9 @@ public class SchemaCompiler {
      *         false otherwise
      */
     public static boolean isSOAP_ENC(String s) {
-        if (s.equals(Constants.URI_SOAP11_ENC))
+        if (s.equals(Constants.URI_SOAP11_ENC)) {
             return true;
+        }
         return s.equals(Constants.URI_SOAP12_ENC);
     }
 
@@ -1003,22 +1034,25 @@ public class SchemaCompiler {
             if (complexType.getName() != null && !this.changedComplexTypeSet.contains(schemaType)) {
                 // here complex type may be in another shcema so we have to find the
                 // correct parent schema.
-                XmlSchema resolvedSchema = getParentSchema(parentSchema,complexType.getQName(),COMPONENT_TYPE);
-                if (resolvedSchema == null){
+                XmlSchema resolvedSchema = getParentSchema(parentSchema, complexType.getQName(),
+                                                           COMPONENT_TYPE);
+                if (resolvedSchema == null) {
                     throw new SchemaCompilationException("can not find the parent schema for the " +
-                            "complex type " + complexType.getQName() + " from the parent schema " +
-                    parentSchema.getTargetNamespace());
+                                                         "complex type " + complexType.getQName() +
+                                                         " from the parent schema " +
+                                                         parentSchema.getTargetNamespace());
                 } else {
-                   processNamedComplexSchemaType(complexType, resolvedSchema);
+                    processNamedComplexSchemaType(complexType, resolvedSchema);
                 }
             } else {
-                processAnonymousComplexSchemaType(xsElt, complexType, parentSchema, isWriteAnonComplexType);
+                processAnonymousComplexSchemaType(xsElt, complexType, parentSchema,
+                                                  isWriteAnonComplexType);
             }
         } else if (schemaType instanceof XmlSchemaSimpleType) {
             //process simple type
             processSimpleSchemaType((XmlSchemaSimpleType) schemaType,
-                    xsElt,
-                    parentSchema, null);
+                                    xsElt,
+                                    parentSchema, null);
         }
     }
 
@@ -1054,11 +1088,13 @@ public class SchemaCompiler {
             javaClassName = writer.makeFullyQualifiedClassName(generatedTypeName);
             processedTypemap.put(generatedTypeName, javaClassName);
             this.processedElementRefMap.put(elt.getQName(), javaClassName);
-            complexType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, javaClassName);
+            complexType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+                                    javaClassName);
         }
 
 
-        BeanWriterMetaInfoHolder metaInfHolder = processComplexType(elt.getQName(),complexType, parentSchema);
+        BeanWriterMetaInfoHolder metaInfHolder = processComplexType(elt.getQName(), complexType,
+                                                                    parentSchema);
 
         // here the only difference is that we generate the class
         // irrespective of where we need it or not
@@ -1080,10 +1116,11 @@ public class SchemaCompiler {
      * @param complexType
      */
     private void processNamedComplexSchemaType(XmlSchemaComplexType complexType,
-                                               XmlSchema parentSchema) throws SchemaCompilationException {
+                                               XmlSchema parentSchema)
+            throws SchemaCompilationException {
 
         if (processedTypemap.containsKey(complexType.getQName())
-                || baseSchemaTypeMap.containsKey(complexType.getQName())) {
+            || baseSchemaTypeMap.containsKey(complexType.getQName())) {
             return;
         }
 
@@ -1093,9 +1130,10 @@ public class SchemaCompiler {
 
         //register that in the schema metainfo bag
         complexType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
-                fullyQualifiedClassName);
+                                fullyQualifiedClassName);
 
-        BeanWriterMetaInfoHolder metaInfHolder = processComplexType(complexType.getQName(),complexType, parentSchema);
+        BeanWriterMetaInfoHolder metaInfHolder = processComplexType(complexType.getQName(),
+                                                                    complexType, parentSchema);
         //add this information to the metainfo holder
         metaInfHolder.setOwnQname(complexType.getQName());
         metaInfHolder.setOwnClassName(fullyQualifiedClassName);
@@ -1113,10 +1151,12 @@ public class SchemaCompiler {
      * @param metaInfHolder
      * @throws SchemaCompilationException
      */
-    private String writeComplexType(XmlSchemaComplexType complexType, BeanWriterMetaInfoHolder metaInfHolder)
+    private String writeComplexType(XmlSchemaComplexType complexType,
+                                    BeanWriterMetaInfoHolder metaInfHolder)
             throws SchemaCompilationException {
         String javaClassName = writer.write(complexType.getQName(),
-                processedTypemap, processedGroupTypeMap, metaInfHolder, complexType.isAbstract());
+                                            processedTypemap, processedGroupTypeMap, metaInfHolder,
+                                            complexType.isAbstract());
         processedTypeMetaInfoMap.put(complexType.getQName(), metaInfHolder);
         return javaClassName;
     }
@@ -1124,16 +1164,18 @@ public class SchemaCompiler {
 
     /**
      * Writes complex Sequence,Choice, all elements
-     * @param qname complex type qname
+     *
+     * @param qname         complex type qname
      * @param metaInfHolder
-     * @return  written java class name
+     * @return written java class name
      * @throws SchemaCompilationException
      */
 
 
-    private String writeComplexParticle(QName qname,BeanWriterMetaInfoHolder metaInfHolder)
+    private String writeComplexParticle(QName qname, BeanWriterMetaInfoHolder metaInfHolder)
             throws SchemaCompilationException {
-       String javaClassName = writer.write(qname, processedTypemap, processedGroupTypeMap, metaInfHolder,false);
+        String javaClassName = writer.write(qname, processedTypemap, processedGroupTypeMap,
+                                            metaInfHolder, false);
         processedTypeMetaInfoMap.put(qname, metaInfHolder);
         return javaClassName;
     }
@@ -1145,7 +1187,8 @@ public class SchemaCompiler {
      * @param metaInfHolder
      * @throws SchemaCompilationException
      */
-    private void writeSimpleType(XmlSchemaSimpleType simpleType, BeanWriterMetaInfoHolder metaInfHolder)
+    private void writeSimpleType(XmlSchemaSimpleType simpleType,
+                                 BeanWriterMetaInfoHolder metaInfHolder)
             throws SchemaCompilationException {
         writer.write(simpleType, processedTypemap, processedGroupTypeMap, metaInfHolder);
         processedTypeMetaInfoMap.put(simpleType.getQName(), metaInfHolder);
@@ -1161,13 +1204,14 @@ public class SchemaCompiler {
             //Process the particle
             processParticle(parentElementQName, particle, metaInfHolder, parentSchema);
         }
-        
-        if(complexType.isMixed()){
-            throw new SchemaCompilationException("XSD complexType with mix content not supported in ADB");
+
+        if (complexType.isMixed()) {
+            throw new SchemaCompilationException("XSD complexType with mix content not " +
+                                                 "supported in ADB");
         }
 
         //process attributes - first look for the explicit attributes
-        processAttributes(complexType.getAttributes(),metaInfHolder,parentSchema);
+        processAttributes(complexType.getAttributes(), metaInfHolder, parentSchema);
 
         //process any attribute
         //somehow the xml schema parser does not seem to pickup the any attribute!!
@@ -1180,44 +1224,63 @@ public class SchemaCompiler {
         //process content ,either  complex or simple
         if (complexType.getContentModel() != null) {
             processContentModel(complexType.getContentModel(),
-                    metaInfHolder,
-                    parentSchema);
+                                metaInfHolder,
+                                parentSchema);
         }
         return metaInfHolder;
     }
 
-    private void processAttributes(XmlSchemaObjectCollection attributes,
+    private void processAttributes(List<XmlSchemaAttributeOrGroupRef> attributes,
                                    BeanWriterMetaInfoHolder metaInfHolder,
                                    XmlSchema parentSchema) throws SchemaCompilationException {
-        Iterator attribIterator = attributes.getIterator();
-        while (attribIterator.hasNext()) {
-            Object o = attribIterator.next();
-            if (o instanceof XmlSchemaAttribute) {
-                processAttribute((XmlSchemaAttribute) o, metaInfHolder, parentSchema);
-            } else if (o instanceof XmlSchemaAttributeGroupRef){
-                processAttributeGroupReference((XmlSchemaAttributeGroupRef)o,metaInfHolder,parentSchema);
+
+        for (XmlSchemaObject object : attributes) {
+            if (object instanceof XmlSchemaAttribute) {
+                processAttribute((XmlSchemaAttribute) object, metaInfHolder, parentSchema);
+            } else if (object instanceof XmlSchemaAttributeGroupRef) {
+                processAttributeGroupReference((XmlSchemaAttributeGroupRef) object, metaInfHolder,
+                                               parentSchema);
             }
         }
     }
 
+    private void processGroupAttributes(List<XmlSchemaAttributeGroupMember> attributes,
+                                        BeanWriterMetaInfoHolder metaInfHolder,
+                                        XmlSchema resolvedSchema)
+            throws SchemaCompilationException {
+        for (XmlSchemaAttributeGroupMember member : attributes) {
+            if (member instanceof XmlSchemaAttribute) {
+                processAttribute((XmlSchemaAttribute) member, metaInfHolder, resolvedSchema);
+            } else if (member instanceof XmlSchemaAttributeGroupRef) {
+                processAttributeGroupReference((XmlSchemaAttributeGroupRef) member, metaInfHolder,
+                                               resolvedSchema);
+            }
+        }
+    }
+
+
     private void processAttributeGroupReference(XmlSchemaAttributeGroupRef attributeGroupRef,
                                                 BeanWriterMetaInfoHolder metaInfHolder,
-                                                XmlSchema parentSchema) throws SchemaCompilationException {
+                                                XmlSchema parentSchema)
+            throws SchemaCompilationException {
 
-        QName attributeGroupRefName = attributeGroupRef.getRefName();
-        if (attributeGroupRefName != null){
-           XmlSchema resolvedSchema = getParentSchema(parentSchema,attributeGroupRefName,COMPONENT_ATTRIBUTE_GROUP);
+        QName attributeGroupRefName = attributeGroupRef.getRef().getTargetQName();
+        if (attributeGroupRefName != null) {
+            XmlSchema resolvedSchema = getParentSchema(parentSchema, attributeGroupRefName,
+                                                       COMPONENT_ATTRIBUTE_GROUP);
             if (resolvedSchema == null) {
                 throw new SchemaCompilationException("can not find the attribute group reference name " +
-                        attributeGroupRefName + " from the parent schema " + parentSchema.getTargetNamespace());
+                                                     attributeGroupRefName + " from the parent schema " +
+                                                     parentSchema.getTargetNamespace());
             } else {
                 XmlSchemaAttributeGroup xmlSchemaAttributeGroup =
-                        (XmlSchemaAttributeGroup) resolvedSchema.getAttributeGroups().getItem(attributeGroupRefName);
+                        resolvedSchema.getAttributeGroups().get(attributeGroupRefName);
                 if (xmlSchemaAttributeGroup != null) {
-                    processAttributes(xmlSchemaAttributeGroup.getAttributes(), metaInfHolder, resolvedSchema);
+                    processGroupAttributes(xmlSchemaAttributeGroup.getAttributes(), metaInfHolder,
+                                           resolvedSchema);
                 } else {
                     throw new SchemaCompilationException("Can not find an attribute group for group reference "
-                            + attributeGroupRefName.getLocalPart());
+                                                         + attributeGroupRefName.getLocalPart());
                 }
             }
 
@@ -1254,15 +1317,18 @@ public class SchemaCompiler {
 
             // to handle extension we need to attach the extended items to the base type
             // and create a new type
-            XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content;
+            XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
 
             //process the base type if it has not been processed yet
             if (!isAlreadyProcessed(extension.getBaseTypeName())) {
                 //pick the relevant basetype from the schema and process it
-                XmlSchema resolvedSchema = getParentSchema(parentSchema, extension.getBaseTypeName(), COMPONENT_TYPE);
+                XmlSchema resolvedSchema = getParentSchema(parentSchema, extension.getBaseTypeName(),
+                                                           COMPONENT_TYPE);
                 if (resolvedSchema == null) {
-                    throw new SchemaCompilationException("can not find the compley type " + extension.getBaseTypeName()
-                            + " from the parent type " + parentSchema.getTargetNamespace());
+                    throw new SchemaCompilationException("can not find the compley type " +
+                                                         extension.getBaseTypeName()
+                                                         + " from the parent type " +
+                                                         parentSchema.getTargetNamespace());
                 } else {
                     XmlSchemaType type = resolvedSchema.getTypeByName(extension.getBaseTypeName());
                     if (type instanceof XmlSchemaComplexType) {
@@ -1290,12 +1356,13 @@ public class SchemaCompiler {
 
             //process the particle of this node
             if (extension.getParticle() != null) {
-                processParticle(extension.getBaseTypeName(),extension.getParticle(), metaInfHolder, parentSchema);
+                processParticle(extension.getBaseTypeName(), extension.getParticle(), metaInfHolder,
+                                parentSchema);
             }
 
             // process attributes
             //process attributes - first look for the explicit attributes
-            processAttributes(extension.getAttributes(),metaInfHolder,parentSchema);
+            processAttributes(extension.getAttributes(), metaInfHolder, parentSchema);
 
             //process any attribute
             //somehow the xml schema parser does not seem to pickup the any attribute!!
@@ -1314,15 +1381,20 @@ public class SchemaCompiler {
                 //Note  - this is no array! so the array boolean is false
             }
         } else if (content instanceof XmlSchemaComplexContentRestriction) {
-            XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
+            XmlSchemaComplexContentRestriction restriction =
+                    (XmlSchemaComplexContentRestriction) content;
 
             //process the base type if it has not been processed yet
             if (!isAlreadyProcessed(restriction.getBaseTypeName())) {
                 //pick the relevant basetype from the schema and process it
-                XmlSchema resolvedSchema = getParentSchema(parentSchema, restriction.getBaseTypeName(), COMPONENT_TYPE);
+                XmlSchema resolvedSchema = getParentSchema(parentSchema,
+                                                           restriction.getBaseTypeName(),
+                                                           COMPONENT_TYPE);
                 if (resolvedSchema == null) {
-                    throw new SchemaCompilationException("can not find the complex type " + restriction.getBaseTypeName()
-                            + " from the parent type " + parentSchema.getTargetNamespace());
+                    throw new SchemaCompilationException("can not find the complex type " +
+                                                         restriction.getBaseTypeName()
+                                                         + " from the parent type " +
+                                                         parentSchema.getTargetNamespace());
                 } else {
                     XmlSchemaType type = resolvedSchema.getTypeByName(restriction.getBaseTypeName());
                     if (type instanceof XmlSchemaComplexType) {
@@ -1335,7 +1407,8 @@ public class SchemaCompiler {
                             throw new SchemaCompilationException("Unnamed complex type used in restriction");//Internationlize this
                         }
                     } else if (type instanceof XmlSchemaSimpleType) {
-                        throw new SchemaCompilationException("Not a valid restriction, complex content restriction base type cannot be a simple type.");
+                        throw new SchemaCompilationException("Not a valid restriction, " +
+                                                             "complex content restriction base type cannot be a simple type.");
                     }
                 }
             }
@@ -1343,10 +1416,11 @@ public class SchemaCompiler {
             copyMetaInfoHierarchy(metaInfHolder, restriction.getBaseTypeName(), parentSchema);
 
             //process the particle of this node
-            processParticle(restriction.getBaseTypeName(),restriction.getParticle(), metaInfHolder, parentSchema);
+            processParticle(restriction.getBaseTypeName(), restriction.getParticle(), metaInfHolder,
+                            parentSchema);
 
             //process attributes - first look for the explicit attributes
-            processAttributes(restriction.getAttributes(),metaInfHolder,parentSchema);
+            processAttributes(restriction.getAttributes(), metaInfHolder, parentSchema);
 
             //process any attribute
             //somehow the xml schema parser does not seem to pickup the any attribute!!
@@ -1358,7 +1432,8 @@ public class SchemaCompiler {
 
             if (!writer.getDefaultClassName().equals(className)) {
                 metaInfHolder.setRestriction(true);
-                metaInfHolder.setRestrictionClassName(findClassName(restriction.getBaseTypeName(), false));
+                metaInfHolder.setRestrictionClassName(findClassName(restriction.getBaseTypeName(),
+                                                                    false));
                 //Note  - this is no array! so the array boolean is false
             }
         }
@@ -1376,10 +1451,11 @@ public class SchemaCompiler {
                                        XmlSchema parentSchema)
             throws SchemaCompilationException {
 
-        XmlSchema resolvedSchema = getParentSchema(parentSchema,baseTypeName,COMPONENT_TYPE);
+        XmlSchema resolvedSchema = getParentSchema(parentSchema, baseTypeName, COMPONENT_TYPE);
         if (resolvedSchema == null) {
             throw new SchemaCompilationException("can not find type " + baseTypeName
-                    + " from the parent schema " + parentSchema.getTargetNamespace());
+                                                 + " from the parent schema " +
+                                                 parentSchema.getTargetNamespace());
         } else {
             XmlSchemaType type = resolvedSchema.getTypeByName(baseTypeName);
             BeanWriterMetaInfoHolder baseMetaInfoHolder =
@@ -1397,50 +1473,57 @@ public class SchemaCompiler {
                         if (content instanceof XmlSchemaComplexContent) {
                             XmlSchemaComplexContent complexContent =
                                     (XmlSchemaComplexContent) content;
-                            if (complexContent.getContent() instanceof XmlSchemaComplexContentExtension) {
+                            if (complexContent.getContent() instanceof
+                                    XmlSchemaComplexContentExtension) {
                                 XmlSchemaComplexContentExtension extension =
                                         (XmlSchemaComplexContentExtension) complexContent.getContent();
                                 //recursively call the copyMetaInfoHierarchy method
                                 copyMetaInfoHierarchy(baseMetaInfoHolder,
-                                        extension.getBaseTypeName(),
-                                        resolvedSchema);
+                                                      extension.getBaseTypeName(),
+                                                      resolvedSchema);
 
-                            } else if (complexContent.getContent() instanceof XmlSchemaComplexContentRestriction) {
+                            } else if (complexContent.getContent() instanceof
+                                    XmlSchemaComplexContentRestriction) {
 
                                 XmlSchemaComplexContentRestriction restriction =
                                         (XmlSchemaComplexContentRestriction) complexContent.getContent();
                                 //recursively call the copyMetaInfoHierarchy method
                                 copyMetaInfoHierarchy(baseMetaInfoHolder,
-                                        restriction.getBaseTypeName(),
-                                        resolvedSchema);
+                                                      restriction.getBaseTypeName(),
+                                                      resolvedSchema);
 
                             } else {
                                 throw new SchemaCompilationException(
-                                        SchemaCompilerMessages.getMessage("schema.unknowncontenterror"));
+                                        SchemaCompilerMessages.
+                                                getMessage("schema.unknowncontenterror"));
                             }
 
                         } else if (content instanceof XmlSchemaSimpleContent) {
 
                             XmlSchemaSimpleContent simpleContent = (XmlSchemaSimpleContent) content;
-                            if (simpleContent.getContent() instanceof XmlSchemaSimpleContentExtension) {
-                                XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension) simpleContent
+                            if (simpleContent.getContent() instanceof
+                                    XmlSchemaSimpleContentExtension) {
+                                XmlSchemaSimpleContentExtension extension =
+                                        (XmlSchemaSimpleContentExtension) simpleContent
                                         .getContent();
                                 // recursively call the copyMetaInfoHierarchy
                                 // method
                                 copyMetaInfoHierarchy(baseMetaInfoHolder,
-                                        extension.getBaseTypeName(), resolvedSchema);
+                                                      extension.getBaseTypeName(), resolvedSchema);
 
-                            } else if (simpleContent.getContent() instanceof XmlSchemaSimpleContentRestriction) {
+                            } else if (simpleContent.getContent() instanceof
+                                    XmlSchemaSimpleContentRestriction) {
 
-                                XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) simpleContent
+                                XmlSchemaSimpleContentRestriction restriction =
+                                        (XmlSchemaSimpleContentRestriction) simpleContent
                                         .getContent();
                                 // recursively call the copyMetaInfoHierarchy
                                 // method
                                 copyMetaInfoHierarchy(baseMetaInfoHolder,
-                                        restriction.getBaseTypeName(), resolvedSchema);
+                                                      restriction.getBaseTypeName(), resolvedSchema);
 
                             }
-                        
+
                         } else {
                             throw new SchemaCompilationException(
                                     SchemaCompilerMessages.getMessage("schema.unknowncontenterror"));
@@ -1457,7 +1540,7 @@ public class SchemaCompiler {
                     // code as union
                     if (baseMetaInfoHolder.isUnion()) {
                         metaInfHolder.setUnion(true);
-                        for (Map.Entry<QName,String> entry : baseMetaInfoHolder.getMemberTypes().entrySet()) {
+                        for (Map.Entry<QName, String> entry : baseMetaInfoHolder.getMemberTypes().entrySet()) {
                             metaInfHolder.addMemberType(entry.getKey(), entry.getValue());
                         }
                     }
@@ -1480,7 +1563,9 @@ public class SchemaCompiler {
      * @param metaInfHolder
      * @throws SchemaCompilationException
      */
-    private void processSimpleContent(XmlSchemaSimpleContent simpleContent, BeanWriterMetaInfoHolder metaInfHolder, XmlSchema parentSchema)
+    private void processSimpleContent(XmlSchemaSimpleContent simpleContent,
+                                      BeanWriterMetaInfoHolder metaInfHolder,
+                                      XmlSchema parentSchema)
             throws SchemaCompilationException {
         XmlSchemaContent content;
         content = simpleContent.getContent();
@@ -1490,10 +1575,13 @@ public class SchemaCompiler {
             //process the base type if it has not been processed yet
             if (!isAlreadyProcessed(extension.getBaseTypeName())) {
                 //pick the relevant basetype from the schema and process it
-                XmlSchema resolvedSchema = getParentSchema(parentSchema, extension.getBaseTypeName(), COMPONENT_TYPE);
+                XmlSchema resolvedSchema = getParentSchema(parentSchema, extension.getBaseTypeName(),
+                                                           COMPONENT_TYPE);
                 if (resolvedSchema == null) {
-                    throw new SchemaCompilationException("can not find type " + extension.getBaseTypeName()
-                            + " from the parent schema " + parentSchema.getTargetNamespace());
+                    throw new SchemaCompilationException("can not find type " +
+                                                         extension.getBaseTypeName()
+                                                         + " from the parent schema " +
+                                                         parentSchema.getTargetNamespace());
                 } else {
                     XmlSchemaType type = resolvedSchema.getTypeByName(extension.getBaseTypeName());
                     if (type instanceof XmlSchemaComplexType) {
@@ -1517,10 +1605,7 @@ public class SchemaCompiler {
             processSimpleExtensionBaseType(extension.getBaseTypeName(), metaInfHolder, parentSchema);
 
             //process attributes
-            XmlSchemaObjectCollection attribs = extension.getAttributes();
-            Iterator attribIterator = attribs.getIterator();
-            while (attribIterator.hasNext()) {
-                Object attr = attribIterator.next();
+            for (XmlSchemaAttributeOrGroupRef attr : extension.getAttributes()) {
                 if (attr instanceof XmlSchemaAttribute) {
                     processAttribute((XmlSchemaAttribute) attr, metaInfHolder, parentSchema);
 
@@ -1539,10 +1624,14 @@ public class SchemaCompiler {
             //process the base type if it has not been processed yet
             if (!isAlreadyProcessed(restriction.getBaseTypeName())) {
                 //pick the relevant basetype from the schema and process it
-                XmlSchema resolvedSchema = getParentSchema(parentSchema, restriction.getBaseTypeName(), COMPONENT_TYPE);
+                XmlSchema resolvedSchema = getParentSchema(parentSchema,
+                                                           restriction.getBaseTypeName(),
+                                                           COMPONENT_TYPE);
                 if (resolvedSchema == null) {
-                    throw new SchemaCompilationException("can not find type " + restriction.getBaseTypeName()
-                            + " from the parent schema " + parentSchema.getTargetNamespace());
+                    throw new SchemaCompilationException("can not find type " +
+                                                         restriction.getBaseTypeName()
+                                                         + " from the parent schema " +
+                                                         parentSchema.getTargetNamespace());
                 } else {
                     XmlSchemaType type = resolvedSchema.getTypeByName(restriction.getBaseTypeName());
 
@@ -1564,13 +1653,14 @@ public class SchemaCompiler {
             }
             //process restriction base type
             processSimpleRestrictionBaseType(restriction.getBaseTypeName(),
-                    restriction.getBaseTypeName(),
-                    metaInfHolder,
-                    parentSchema);
+                                             restriction.getBaseTypeName(),
+                                             metaInfHolder,
+                                             parentSchema);
             metaInfHolder.setSimple(true);
-            
-            if (!SchemaConstants.XSD_BOOLEAN.equals(restriction.getBaseTypeName())){
-                processFacets(restriction.getFacets(), restriction.getBaseTypeName(), metaInfHolder, parentSchema);
+
+            if (!SchemaConstants.XSD_BOOLEAN.equals(restriction.getBaseTypeName())) {
+                processFacets(restriction.getFacets(), restriction.getBaseTypeName(), metaInfHolder,
+                              parentSchema);
             }
         }
     }
@@ -1583,7 +1673,8 @@ public class SchemaCompiler {
      */
     public void processSimpleExtensionBaseType(QName extBaseType,
                                                BeanWriterMetaInfoHolder metaInfHolder,
-                                               XmlSchema parentSchema) throws SchemaCompilationException {
+                                               XmlSchema parentSchema)
+            throws SchemaCompilationException {
 
         //find the class name
         String className = findClassName(extBaseType, false);
@@ -1597,21 +1688,22 @@ public class SchemaCompiler {
             //this means the schema type actually returns a different QName
             if (changedTypeMap.containsKey(extBaseType)) {
                 metaInfHolder.registerMapping(extBaseType,
-                        changedTypeMap.get(extBaseType),
-                        className, SchemaConstants.ELEMENT_TYPE);
+                                              changedTypeMap.get(extBaseType),
+                                              className, SchemaConstants.ELEMENT_TYPE);
             } else {
                 metaInfHolder.registerMapping(extBaseType,
-                        extBaseType,
-                        className, SchemaConstants.ELEMENT_TYPE);
+                                              extBaseType,
+                                              className, SchemaConstants.ELEMENT_TYPE);
             }
             metaInfHolder.setSimple(true);
             // we have already process when it comes to this place
         } else if (processedTypemap.containsKey(extBaseType)) {
             //set the extension base class name
-            XmlSchema resolvedSchema = getParentSchema(parentSchema,extBaseType,COMPONENT_TYPE);
+            XmlSchema resolvedSchema = getParentSchema(parentSchema, extBaseType, COMPONENT_TYPE);
             if (resolvedSchema == null) {
                 throw new SchemaCompilationException("can not find the type " + extBaseType
-                        + " from the parent schema " + parentSchema.getTargetNamespace());
+                                                     + " from the parent schema " +
+                                                     parentSchema.getTargetNamespace());
             } else {
                 XmlSchemaType type = resolvedSchema.getTypeByName(extBaseType);
                 if (type instanceof XmlSchemaSimpleType) {
@@ -1622,16 +1714,15 @@ public class SchemaCompiler {
                     copyMetaInfoHierarchy(metaInfHolder, extBaseType, resolvedSchema);
                 } else if (type instanceof XmlSchemaComplexType) {
                     XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
-                        // do not set as a simple type since we want to
-                        // print the element names
-                        metaInfHolder.setExtension(true);
-                        metaInfHolder.setExtensionClassName(className);
-                        copyMetaInfoHierarchy(metaInfHolder, extBaseType, resolvedSchema);
-                        XmlSchemaContentModel typeContent =complexType.getContentModel();
-                        if(typeContent != null && typeContent instanceof XmlSchemaSimpleContent){
-                            metaInfHolder.setSimple(true);                            
-                        } 
-                        
+                    // do not set as a simple type since we want to
+                    // print the element names
+                    metaInfHolder.setExtension(true);
+                    metaInfHolder.setExtensionClassName(className);
+                    copyMetaInfoHierarchy(metaInfHolder, extBaseType, resolvedSchema);
+                    XmlSchemaContentModel typeContent = complexType.getContentModel();
+                    if (typeContent != null && typeContent instanceof XmlSchemaSimpleContent) {
+                        metaInfHolder.setSimple(true);
+                    }
                 }
             }
 
@@ -1642,7 +1733,7 @@ public class SchemaCompiler {
         //get the binary state and add that to the status map
         if (isBinary(extBaseType)) {
             metaInfHolder.addtStatus(extBaseType,
-                    SchemaConstants.BINARY_TYPE);
+                                     SchemaConstants.BINARY_TYPE);
         }
     }
 
@@ -1655,7 +1746,8 @@ public class SchemaCompiler {
     public void processSimpleRestrictionBaseType(QName qName,
                                                  QName resBaseType,
                                                  BeanWriterMetaInfoHolder metaInfHolder,
-                                                 XmlSchema parentSchema) throws SchemaCompilationException {
+                                                 XmlSchema parentSchema)
+            throws SchemaCompilationException {
 
         //find the class name
         String className = findClassName(resBaseType, false);
@@ -1664,12 +1756,12 @@ public class SchemaCompiler {
         if (baseSchemaTypeMap.containsKey(resBaseType)) {
             if (changedTypeMap.containsKey(resBaseType)) {
                 metaInfHolder.registerMapping(qName,
-                        changedTypeMap.get(resBaseType),
-                        className, SchemaConstants.ELEMENT_TYPE);
+                                              changedTypeMap.get(resBaseType),
+                                              className, SchemaConstants.ELEMENT_TYPE);
             } else {
                 metaInfHolder.registerMapping(qName,
-                        resBaseType,
-                        className, SchemaConstants.ELEMENT_TYPE);
+                                              resBaseType,
+                                              className, SchemaConstants.ELEMENT_TYPE);
             }
         } else if (processedTypemap.containsKey(resBaseType)) {
             //this is not a standared type
@@ -1689,34 +1781,28 @@ public class SchemaCompiler {
      * Process Facets.
      *
      * @param metaInfHolder
-     * @param facets 
+     * @param facets
      */
-    private void processFacets( XmlSchemaObjectCollection facets,QName restrictionName,
+    private void processFacets(List<XmlSchemaFacet> facets, QName restrictionName,
                                BeanWriterMetaInfoHolder metaInfHolder,
                                XmlSchema parentSchema) {
-        
-        Iterator facetIterator = facets.getIterator();
-
-        while (facetIterator.hasNext()) {
-            Object obj = facetIterator.next();
 
-            if (obj instanceof XmlSchemaPatternFacet) {
-                XmlSchemaPatternFacet pattern = (XmlSchemaPatternFacet) obj;
+        for (XmlSchemaFacet facet : facets) {
+            if (facet instanceof XmlSchemaPatternFacet) {
+                XmlSchemaPatternFacet pattern = (XmlSchemaPatternFacet) facet;
                 // some patterns contain \ so we have to replace them
                 String patternString = pattern.getValue().toString();
                 // replace backword slashes
                 patternString = patternString.replaceAll("\\\\", "\\\\\\\\");
-                patternString = patternString.replaceAll("\"","\\\\\"");
+                patternString = patternString.replaceAll("\"", "\\\\\"");
                 if ((metaInfHolder.getPatternFacet() != null) &&
-                        (metaInfHolder.getPatternFacet().trim().length() > 0)){
+                    (metaInfHolder.getPatternFacet().trim().length() > 0)) {
                     // i.e there is a pattern faceset
                     patternString = metaInfHolder.getPatternFacet().trim() + "|" + patternString;
                 }
                 metaInfHolder.setPatternFacet(patternString);
-            }
-
-            else if (obj instanceof XmlSchemaEnumerationFacet) {
-                XmlSchemaEnumerationFacet enumeration = (XmlSchemaEnumerationFacet) obj;
+            } else if (facet instanceof XmlSchemaEnumerationFacet) {
+                XmlSchemaEnumerationFacet enumeration = (XmlSchemaEnumerationFacet) facet;
                 if (restrictionName.equals(SchemaConstants.XSD_QNAME)) {
                     // we have to process the qname here and shoud find the local part and namespace uri
                     String value = enumeration.getValue().toString();
@@ -1731,45 +1817,29 @@ public class SchemaCompiler {
                     metaInfHolder.addEnumFacet(enumeration.getValue().toString());
                 }
 
-            }
-
-            else if (obj instanceof XmlSchemaLengthFacet) {
-                XmlSchemaLengthFacet length = (XmlSchemaLengthFacet) obj;
+            } else if (facet instanceof XmlSchemaLengthFacet) {
+                XmlSchemaLengthFacet length = (XmlSchemaLengthFacet) facet;
                 metaInfHolder.setLengthFacet(Integer.parseInt(length.getValue().toString()));
-            }
-
-            else if (obj instanceof XmlSchemaTotalDigitsFacet) {
-                XmlSchemaTotalDigitsFacet totalDigits = (XmlSchemaTotalDigitsFacet) obj;
+            } else if (facet instanceof XmlSchemaTotalDigitsFacet) {
+                XmlSchemaTotalDigitsFacet totalDigits = (XmlSchemaTotalDigitsFacet) facet;
                 metaInfHolder.setTotalDigitsFacet(totalDigits.getValue().toString());
-            }
-
-            else if (obj instanceof XmlSchemaMaxExclusiveFacet) {
-                XmlSchemaMaxExclusiveFacet maxEx = (XmlSchemaMaxExclusiveFacet) obj;
+            } else if (facet instanceof XmlSchemaMaxExclusiveFacet) {
+                XmlSchemaMaxExclusiveFacet maxEx = (XmlSchemaMaxExclusiveFacet) facet;
                 metaInfHolder.setMaxExclusiveFacet(maxEx.getValue().toString());
-            }
-
-            else if (obj instanceof XmlSchemaMinExclusiveFacet) {
-                XmlSchemaMinExclusiveFacet minEx = (XmlSchemaMinExclusiveFacet) obj;
+            } else if (facet instanceof XmlSchemaMinExclusiveFacet) {
+                XmlSchemaMinExclusiveFacet minEx = (XmlSchemaMinExclusiveFacet) facet;
                 metaInfHolder.setMinExclusiveFacet(minEx.getValue().toString());
-            }
-
-            else if (obj instanceof XmlSchemaMaxInclusiveFacet) {
-                XmlSchemaMaxInclusiveFacet maxIn = (XmlSchemaMaxInclusiveFacet) obj;
+            } else if (facet instanceof XmlSchemaMaxInclusiveFacet) {
+                XmlSchemaMaxInclusiveFacet maxIn = (XmlSchemaMaxInclusiveFacet) facet;
                 metaInfHolder.setMaxInclusiveFacet(maxIn.getValue().toString());
-            }
-
-            else if (obj instanceof XmlSchemaMinInclusiveFacet) {
-                XmlSchemaMinInclusiveFacet minIn = (XmlSchemaMinInclusiveFacet) obj;
+            } else if (facet instanceof XmlSchemaMinInclusiveFacet) {
+                XmlSchemaMinInclusiveFacet minIn = (XmlSchemaMinInclusiveFacet) facet;
                 metaInfHolder.setMinInclusiveFacet(minIn.getValue().toString());
-            }
-
-            else if (obj instanceof XmlSchemaMaxLengthFacet) {
-                XmlSchemaMaxLengthFacet maxLen = (XmlSchemaMaxLengthFacet) obj;
+            } else if (facet instanceof XmlSchemaMaxLengthFacet) {
+                XmlSchemaMaxLengthFacet maxLen = (XmlSchemaMaxLengthFacet) facet;
                 metaInfHolder.setMaxLengthFacet(Integer.parseInt(maxLen.getValue().toString()));
-            }
-
-            else if (obj instanceof XmlSchemaMinLengthFacet) {
-                XmlSchemaMinLengthFacet minLen = (XmlSchemaMinLengthFacet) obj;
+            } else if (facet instanceof XmlSchemaMinLengthFacet) {
+                XmlSchemaMinLengthFacet minLen = (XmlSchemaMinLengthFacet) facet;
                 metaInfHolder.setMinLengthFacet(Integer.parseInt(minLen.getValue().toString()));
             }
         }
@@ -1780,17 +1850,18 @@ public class SchemaCompiler {
      *
      * @param metainf
      */
-    private void processAnyAttribute(BeanWriterMetaInfoHolder metainf, XmlSchemaAnyAttribute anyAtt) {
+    private void processAnyAttribute(BeanWriterMetaInfoHolder metainf,
+                                     XmlSchemaAnyAttribute anyAtt) {
 
         //The best thing we can do here is to add a set of OMAttributes
         //since attributes do not have the notion of minoccurs/maxoccurs the
         //safest option here is to have an OMAttribute array
         QName qName = new QName(EXTRA_ATTRIBUTE_FIELD_NAME);
         metainf.registerMapping(qName,
-                null,
-                writer.getDefaultAttribArrayClassName(),//always generate an array of
-                //OMAttributes
-                SchemaConstants.ANY_TYPE);
+                                null,
+                                writer.getDefaultAttribArrayClassName(),//always generate an array of
+                                //OMAttributes
+                                SchemaConstants.ANY_TYPE);
         metainf.addtStatus(qName, SchemaConstants.ATTRIBUTE_TYPE);
         metainf.addtStatus(qName, SchemaConstants.ARRAY_TYPE);
 
@@ -1803,7 +1874,8 @@ public class SchemaCompiler {
      * @param att
      * @param metainf
      */
-    public void processAttribute(XmlSchemaAttribute att, BeanWriterMetaInfoHolder metainf, XmlSchema parentSchema)
+    public void processAttribute(XmlSchemaAttribute att, BeanWriterMetaInfoHolder metainf,
+                                 XmlSchema parentSchema)
             throws SchemaCompilationException {
 
         QName schemaTypeName = att.getSchemaTypeName();
@@ -1812,10 +1884,11 @@ public class SchemaCompiler {
                 if (baseSchemaTypeMap.containsKey(schemaTypeName)) {
 
                     metainf.registerMapping(att.getQName(), schemaTypeName,
-                            baseSchemaTypeMap.get(schemaTypeName).toString(), SchemaConstants.ATTRIBUTE_TYPE);
+                                            baseSchemaTypeMap.get(schemaTypeName).toString(),
+                                            SchemaConstants.ATTRIBUTE_TYPE);
 
                     // add optional attribute status if set
-                    String use = att.getUse().getValue();
+                    String use = att.getUse().toString();
                     if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)) {
                         metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
                     }
@@ -1826,19 +1899,22 @@ public class SchemaCompiler {
                             SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
                             className);
                     // set the default value
-                    if (att.getDefaultValue() != null){
-                        metainf.registerDefaultValue(att.getQName(),att.getDefaultValue());
-                    }                 
-                    if(att.getFixedValue() != null){
+                    if (att.getDefaultValue() != null) {
+                        metainf.registerDefaultValue(att.getQName(), att.getDefaultValue());
+                    }
+                    if (att.getFixedValue() != null) {
                         metainf.registerDefaultValue(att.getQName(), att.getFixedValue());
                         metainf.setFixed(true);

[... 1345 lines stripped ...]