You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by bi...@apache.org on 2008/12/15 00:18:59 UTC

svn commit: r726576 [5/10] - in /webservices/commons/trunk/modules/XmlSchema: ./ etc/ etc/eclipse/ src/main/java/org/apache/ws/commons/schema/ src/main/java/org/apache/ws/commons/schema/constants/ src/main/java/org/apache/ws/commons/schema/extensions/ ...

Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java Sun Dec 14 15:18:54 2008
@@ -44,11 +44,10 @@
 import org.w3c.dom.Text;
 
 /**
- * Convert from the XML Schema class representation to the standard
- * XML representation. 
-  */
+ * Convert from the XML Schema class representation to the standard XML representation.
+ */
 public class XmlSchemaSerializer {
-	
+
     /**
      * Extension registry for the serializer
      */
@@ -57,6 +56,7 @@
 
     /**
      * Get the registry of extensions for this serializer.
+     * 
      * @return the registry.
      */
     public ExtensionRegistry getExtReg() {
@@ -65,13 +65,13 @@
 
     /**
      * Set the registry of extensions for this serializer.
+     * 
      * @param extReg the registry.
      */
     public void setExtReg(ExtensionRegistry extReg) {
         this.extReg = extReg;
     }
 
-
     private Hashtable schema_ns;
 
     static String xsdPrefix = "xs";
@@ -90,21 +90,21 @@
     }
 
     /**
-     * Serialize an entire schema, returning an array of DOM Documents, one per XSL file. 
+     * Serialize an entire schema, returning an array of DOM Documents, one per XSL file.
+     * 
      * @param schemaObj The XML Schema.
-     * @param serializeIncluded whether to create DOM trees for any included or imported 
-     * schemas.
-     * @return Documents. If serializeIncluded is false, the array with have one entry.
-     * The main document is always first.
+     * @param serializeIncluded whether to create DOM trees for any included or imported schemas.
+     * @return Documents. If serializeIncluded is false, the array with have one entry. The main document is
+     *         always first.
      * @throws XmlSchemaSerializerException
      */
-    public Document[] serializeSchema(XmlSchema schemaObj,
-                                             boolean serializeIncluded) throws XmlSchemaSerializerException {
+    public Document[] serializeSchema(XmlSchema schemaObj, boolean serializeIncluded)
+        throws XmlSchemaSerializerException {
         return serializeSchemaElement(schemaObj, serializeIncluded);
     }
 
-    Document[] serializeSchemaElement(XmlSchema schemaObj,
-                                      boolean serializeIncluded) throws XmlSchemaSerializerException {
+    Document[] serializeSchemaElement(XmlSchema schemaObj, boolean serializeIncluded)
+        throws XmlSchemaSerializerException {
 
         XmlSchemaObjectCollection items = schemaObj.getItems();
         Document serializedSchemaDocs;
@@ -125,55 +125,54 @@
         if (schemaObj.syntacticalTargetNamespace != null) {
             serializedSchema.setAttribute("targetNamespace", schemaObj.syntacticalTargetNamespace);
 
-            Object targetNS =
-                    schema_ns.get(schemaObj.syntacticalTargetNamespace);
+            Object targetNS = schema_ns.get(schemaObj.syntacticalTargetNamespace);
 
-            //if the namespace is not entered then add 
-            //the targetNamespace as its
+            // if the namespace is not entered then add
+            // the targetNamespace as its
             if (targetNS == null) {
-                if(!Constants.XMLNS_URI.equals(schemaObj.syntacticalTargetNamespace)){
-                    serializedSchema.setAttributeNS(XMLNS_NAMESPACE_URI,
-                            "xmlns", schemaObj.syntacticalTargetNamespace);
+                if (!Constants.XMLNS_URI.equals(schemaObj.syntacticalTargetNamespace)) {
+                    serializedSchema.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns",
+                                                    schemaObj.syntacticalTargetNamespace);
                 }
                 String prefix = null;
-                if(schemaObj.getNamespaceContext() != null) {
+                if (schemaObj.getNamespaceContext() != null) {
                     prefix = schemaObj.getNamespaceContext().getPrefix(schemaObj.syntacticalTargetNamespace);
                 }
-                if(prefix == null && schemaObj.parent != null && schemaObj.parent.getNamespaceContext() != null) {
-                    prefix = schemaObj.parent.getNamespaceContext().getPrefix(schemaObj.syntacticalTargetNamespace);
+                if (prefix == null && schemaObj.parent != null
+                    && schemaObj.parent.getNamespaceContext() != null) {
+                    prefix = schemaObj.parent.getNamespaceContext()
+                        .getPrefix(schemaObj.syntacticalTargetNamespace);
                 }
-                if(prefix == null) {
+                if (prefix == null) {
                     prefix = "";
                 }
                 schema_ns.put(schemaObj.syntacticalTargetNamespace, prefix);
             }
         }
 
-
-        //todo: implement xml:lang, 
+        // todo: implement xml:lang,
         if (schemaObj.attributeFormDefault != null) {
             String formQualified = schemaObj.attributeFormDefault.getValue();
 
-            if (!formQualified.equals(XmlSchemaForm.NONE))
+            if (!formQualified.equals(XmlSchemaForm.NONE)) {
                 serializedSchema.setAttribute("attributeFormDefault", convertString(formQualified));
+            }
         }
 
         if (schemaObj.elementFormDefault != null) {
             String formQualified = schemaObj.elementFormDefault.getValue();
 
-            if (!formQualified.equals(XmlSchemaForm.NONE))
+            if (!formQualified.equals(XmlSchemaForm.NONE)) {
                 serializedSchema.setAttribute("elementFormDefault", convertString(formQualified));
+            }
         }
 
-
         if (schemaObj.annotation != null) {
-            Element annotation = serializeAnnotation(serializedSchemaDocs,
-                    schemaObj.annotation, schemaObj);
+            Element annotation = serializeAnnotation(serializedSchemaDocs, schemaObj.annotation, schemaObj);
             serializedSchema.appendChild(annotation);
         }
         if (schemaObj.id != null) {
-            serializedSchema.setAttribute("id",
-                    schemaObj.id);
+            serializedSchema.setAttribute("id", schemaObj.id);
         }
         if (schemaObj.blockDefault != null) {
             String blockDefault = schemaObj.blockDefault.getValue();
@@ -194,65 +193,57 @@
             serializedSchema.setAttribute("version", schemaObj.version);
         }
 
-        //add the extra namespace decalarations if any are available
+        // add the extra namespace decalarations if any are available
         NamespacePrefixList ctx = schemaObj.getNamespaceContext();
         String[] prefixes = ctx.getDeclaredPrefixes();
-        for (int i = 0;  i < prefixes.length;  i++) {
-            String prefix = prefixes[i];
+        for (String prefix : prefixes) {
             String uri = ctx.getNamespaceURI(prefix);
             if (!Constants.DEFAULT_NS_PREFIX.equals(prefix)) {
-                serializedSchema.setAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI,
-                        Constants.XMLNS_ATTRIBUTE + ":" + prefix, uri);
+                serializedSchema.setAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI, Constants.XMLNS_ATTRIBUTE
+                                                                                  + ":" + prefix, uri);
             }
         }
 
-        //after serialize the schema add into documentation
-        //and add to document collection array  which at the end 
-        //returned
-        serializeSchemaChild(items, serializedSchema, serializedSchemaDocs,
-                schemaObj, serializeIncluded);
-
-        //process extension elements/attributes
-        processExtensibilityComponents(schemaObj,serializedSchema);
+        // after serialize the schema add into documentation
+        // and add to document collection array which at the end
+        // returned
+        serializeSchemaChild(items, serializedSchema, serializedSchemaDocs, schemaObj, serializeIncluded);
 
+        // process extension elements/attributes
+        processExtensibilityComponents(schemaObj, serializedSchema);
 
         serializedSchemaDocs.appendChild(serializedSchema);
         docs.add(serializedSchemaDocs);
 
-
         Document[] serializedDocs = new Document[docs.size()];
         docs.toArray(serializedDocs);
 
         return serializedDocs;
     }
 
-    private void serializeSchemaChild(XmlSchemaObjectCollection items,
-                                      Element serializedSchema, Document serializedSchemaDocs,
-                                      XmlSchema schemaObj, boolean serializeIncluded)
-            throws XmlSchemaSerializerException {
+    private void serializeSchemaChild(XmlSchemaObjectCollection items, Element serializedSchema,
+                                      Document serializedSchemaDocs, XmlSchema schemaObj,
+                                      boolean serializeIncluded) throws XmlSchemaSerializerException {
 
         int itemsLength = items.getCount();
         /**
-         * For each of the items that belong to this schema, 
-         * serialize each member found.  
-         * Permittable member is: element, simpleType, complexType,
-         * group, attrributeGroup, Attribute, include, import and redefine.
-         * if any of the member found then serialize the component.
+         * For each of the items that belong to this schema, serialize each member found. Permittable member
+         * is: element, simpleType, complexType, group, attrributeGroup, Attribute, include, import and
+         * redefine. if any of the member found then serialize the component.
          */
 
         // Since imports and includes need to be the first items of the
         // serialized schema. So this loop does the serialization of the
         // imports and includes
-
         for (int i = 0; i < itemsLength; i++) {
             XmlSchemaObject obj = items.getItem(i);
             if (obj instanceof XmlSchemaInclude) {
-                Element e = serializeInclude(serializedSchemaDocs,
-                        (XmlSchemaInclude) obj, schemaObj, serializeIncluded);
+                Element e = serializeInclude(serializedSchemaDocs, (XmlSchemaInclude)obj, schemaObj,
+                                             serializeIncluded);
                 serializedSchema.appendChild(e);
             } else if (obj instanceof XmlSchemaImport) {
-                Element e = serializeImport(serializedSchemaDocs,
-                        (XmlSchemaImport) obj, schemaObj, serializeIncluded);
+                Element e = serializeImport(serializedSchemaDocs, (XmlSchemaImport)obj, schemaObj,
+                                            serializeIncluded);
                 serializedSchema.appendChild(e);
             }
         }
@@ -262,364 +253,318 @@
             XmlSchemaObject obj = items.getItem(i);
 
             if (obj instanceof XmlSchemaElement) {
-                Element e = serializeElement(serializedSchemaDocs,
-                        (XmlSchemaElement) obj, schemaObj);
+                Element e = serializeElement(serializedSchemaDocs, (XmlSchemaElement)obj, schemaObj);
                 serializedSchema.appendChild(e);
 
             } else if (obj instanceof XmlSchemaSimpleType) {
-                Element e = serializeSimpleType(serializedSchemaDocs,
-                        (XmlSchemaSimpleType) obj, schemaObj);
+                Element e = serializeSimpleType(serializedSchemaDocs, (XmlSchemaSimpleType)obj, schemaObj);
                 serializedSchema.appendChild(e);
             } else if (obj instanceof XmlSchemaComplexType) {
-                Element e = serializeComplexType(serializedSchemaDocs,
-                        (XmlSchemaComplexType) obj, schemaObj);
+                Element e = serializeComplexType(serializedSchemaDocs, (XmlSchemaComplexType)obj, schemaObj);
                 serializedSchema.appendChild(e);
             } else if (obj instanceof XmlSchemaGroup) {
-                Element e = serializeGroup(serializedSchemaDocs,
-                        (XmlSchemaGroup) obj, schemaObj);
+                Element e = serializeGroup(serializedSchemaDocs, (XmlSchemaGroup)obj, schemaObj);
                 serializedSchema.appendChild(e);
             } else if (obj instanceof XmlSchemaAttributeGroup) {
-                Element e = serializeAttributeGroup(serializedSchemaDocs,
-                        (XmlSchemaAttributeGroup) obj, schemaObj);
+                Element e = serializeAttributeGroup(serializedSchemaDocs, (XmlSchemaAttributeGroup)obj,
+                                                    schemaObj);
                 serializedSchema.appendChild(e);
             } else if (obj instanceof XmlSchemaAttribute) {
-                Element e = serializeAttribute(serializedSchemaDocs,
-                        (XmlSchemaAttribute) obj, schemaObj);
+                Element e = serializeAttribute(serializedSchemaDocs, (XmlSchemaAttribute)obj, schemaObj);
                 serializedSchema.appendChild(e);
             } else if (obj instanceof XmlSchemaRedefine) {
-                Element e = serializeRedefine(serializedSchemaDocs,
-                        (XmlSchemaRedefine) obj, schemaObj);
+                Element e = serializeRedefine(serializedSchemaDocs, (XmlSchemaRedefine)obj, schemaObj);
                 serializedSchema.appendChild(e);
             }
         }
     }
 
     /**
-     * Set up <schema> namespaces appropriately and append that attr
-     * into specified element
+     * Set up <schema> namespaces appropriately and append that attr into specified element
      */
     private Element setupNamespaces(Document schemaDocs, XmlSchema schemaObj) {
         NamespacePrefixList ctx = schemaObj.getNamespaceContext();
         schemaObj.schema_ns_prefix = xsdPrefix = ctx.getPrefix(xsdNamespace);
-        if(xsdPrefix == null) {
+        if (xsdPrefix == null) {
             schemaObj.schema_ns_prefix = xsdPrefix = "";
         }
         String[] prefixes = ctx.getDeclaredPrefixes();
-        for (int i = 0;  i < prefixes.length;  i++) {
-            String prefix = prefixes[i];
+        for (String prefix : prefixes) {
             String uri = ctx.getNamespaceURI(prefix);
-            if(uri != null && prefix != null) {
+            if (uri != null && prefix != null) {
                 schema_ns.put(uri, prefix);
             }
         }
-        //for schema that not set the xmlns attrib member
+        // for schema that not set the xmlns attrib member
         if (schema_ns.get(xsdNamespace) == null) {
             schema_ns.put(xsdNamespace, xsdPrefix);
             schemaObj.schema_ns_prefix = xsdPrefix;
         }
 
-        Element schemaEl = createNewElement(schemaDocs, "schema",
-                schemaObj.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element schemaEl = createNewElement(schemaDocs, "schema", schemaObj.schema_ns_prefix,
+                                            XmlSchema.SCHEMA_NS);
 
         Iterator entries = schema_ns.entrySet().iterator();
 
         while (entries.hasNext()) {
-            //let it crash for null pointer because then either the schema
-            //is wrong(namespace not set properly or bug in setting ns)
-            Map.Entry entry = (Map.Entry) entries.next();
+            // let it crash for null pointer because then either the schema
+            // is wrong(namespace not set properly or bug in setting ns)
+            Map.Entry entry = (Map.Entry)entries.next();
             String key = entry.getKey().toString();
             String value = entry.getValue().toString();
-            value = (value.length() > 0) ? "xmlns:" + value : "xmlns";
-            schemaEl.setAttributeNS(XMLNS_NAMESPACE_URI,
-                    value, key);
+            value = value.length() > 0 ? "xmlns:" + value : "xmlns";
+            schemaEl.setAttributeNS(XMLNS_NAMESPACE_URI, value, key);
         }
         return schemaEl;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeInclude(Document doc, XmlSchemaInclude includeObj,
-     * XmlSchema schema)throws XmlSchemaSerializerException
+     * ********************************************************************* Element serializeInclude(Document
+     * doc, XmlSchemaInclude includeObj, XmlSchema schema)throws XmlSchemaSerializerException
      * <p/>
-     * set appropriate attribute as per this object attribute availability.
-     * Call included schema to append to this schema document collection.
-     * Then add the document created into document pool.
+     * set appropriate attribute as per this object attribute availability. Call included schema to append to
+     * this schema document collection. Then add the document created into document pool.
      * <p/>
-     * Parameter:
-     * doc          - Document the parent use.
-     * includeObj   - XmlSchemaInclude that will be serialized.
-     * schema       - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. includeObj - XmlSchemaInclude that will be serialized. schema
+     * - Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element object representation of XmlSchemaInclude
+     * Return: Element object representation of XmlSchemaInclude
      * **********************************************************************
      */
-    Element serializeInclude(Document doc, XmlSchemaInclude includeObj,
-                             XmlSchema schema, boolean serializeIncluded)
-            throws XmlSchemaSerializerException {
+    Element serializeInclude(Document doc, XmlSchemaInclude includeObj, XmlSchema schema,
+                             boolean serializeIncluded) throws XmlSchemaSerializerException {
 
-        Element includeEl = createNewElement(doc, "include",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element includeEl = createNewElement(doc, "include", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
         if (includeObj.schemaLocation != null) {
-            includeEl.setAttribute("schemaLocation",
-                    includeObj.schemaLocation);
+            includeEl.setAttribute("schemaLocation", includeObj.schemaLocation);
         }
 
-        if (includeObj.id != null)
+        if (includeObj.id != null) {
             includeEl.setAttribute("id", includeObj.id);
+        }
 
         if (includeObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc,
-                    includeObj.annotation, schema);
+            Element annotation = serializeAnnotation(doc, includeObj.annotation, schema);
             includeEl.appendChild(annotation);
         }
 
-        //Get the XmlSchema obj and append that to the content
+        // Get the XmlSchema obj and append that to the content
         XmlSchema includedSchemaObj = includeObj.getSchema();
         if (includedSchemaObj != null && serializeIncluded) {
             XmlSchemaSerializer includeSeri = new XmlSchemaSerializer();
             includeSeri.serializeSchemaElement(includedSchemaObj, true);
-//            XmlSchemaObjectCollection ii = includedSchemaObj.getItems();
+            // XmlSchemaObjectCollection ii = includedSchemaObj.getItems();
             docs.addAll(includeSeri.docs);
         }
 
-        //process includes
-        processExtensibilityComponents(includeObj,includeEl);
+        // process includes
+        processExtensibilityComponents(includeObj, includeEl);
 
         return includeEl;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeImport(Document doc, XmlSchemaImport importObj,
-     * XmlSchema schema)throws XmlSchemaSerializerException
+     * ********************************************************************* Element serializeImport(Document
+     * doc, XmlSchemaImport importObj, XmlSchema schema)throws XmlSchemaSerializerException
      * <p/>
-     * Add each of the attribute of XmlSchemaImport obj into import Element
-     * Then serialize schema that is included by this import.  Include the
-     * serialized schema into document pool.
+     * Add each of the attribute of XmlSchemaImport obj into import Element Then serialize schema that is
+     * included by this import. Include the serialized schema into document pool.
      * <p/>
-     * Parameter:
-     * doc          - Document the parent use.
-     * includeObj   - XmlSchemaInclude that will be serialized.
-     * schema       - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. includeObj - XmlSchemaInclude that will be serialized. schema
+     * - Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element object representation of XmlSchemaImport
+     * Return: Element object representation of XmlSchemaImport
      * **********************************************************************
      */
-    Element serializeImport(Document doc, XmlSchemaImport importObj,
-                            XmlSchema schema, boolean serializeIncluded)
-            throws XmlSchemaSerializerException {
+    Element serializeImport(Document doc, XmlSchemaImport importObj, XmlSchema schema,
+                            boolean serializeIncluded) throws XmlSchemaSerializerException {
 
-        Element importEl = createNewElement(doc, "import",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element importEl = createNewElement(doc, "import", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
-        if (importObj.namespace != null)
-            importEl.setAttribute("namespace",
-                    importObj.namespace);
+        if (importObj.namespace != null) {
+            importEl.setAttribute("namespace", importObj.namespace);
+        }
 
-        if (importObj.schemaLocation != null && !importObj.schemaLocation.trim().equals(""))
-            importEl.setAttribute("schemaLocation",
-                    importObj.schemaLocation);
+        if (importObj.schemaLocation != null && !importObj.schemaLocation.trim().equals("")) {
+            importEl.setAttribute("schemaLocation", importObj.schemaLocation);
+        }
 
-        if (importObj.id != null)
+        if (importObj.id != null) {
             importEl.setAttribute("id", importObj.id);
+        }
 
         if (importObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc,
-                    importObj.annotation, schema);
+            Element annotation = serializeAnnotation(doc, importObj.annotation, schema);
 
             importEl.appendChild(annotation);
         }
 
         if (importObj.schema != null && serializeIncluded) {
 
-
             XmlSchemaSerializer importSeri = new XmlSchemaSerializer();
             importSeri.serializeSchemaElement(importObj.schema, serializeIncluded);
             docs.addAll(importSeri.docs);
         }
 
-         //process extension
-        processExtensibilityComponents(importObj,importEl);
+        // process extension
+        processExtensibilityComponents(importObj, importEl);
 
         return importEl;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeRedefine(Document doc, XmlSchemaRedefine redefineObj,
-     * XmlSchema schema)throws XmlSchemaSerializerException
+     * ********************************************************************* Element
+     * serializeRedefine(Document doc, XmlSchemaRedefine redefineObj, XmlSchema schema)throws
+     * XmlSchemaSerializerException
      * <p/>
-     * Add each of the attribute of XmlSchemaImport obj into import Element
-     * Then serialize schema that is included by this import.  Include the
-     * serialized schema into document pool.
+     * Add each of the attribute of XmlSchemaImport obj into import Element Then serialize schema that is
+     * included by this import. Include the serialized schema into document pool.
      * <p/>
-     * Parameter:
-     * doc           - Document the parent use.
-     * redefineObj   - XmlSchemaInclude that will be serialized.
-     * schema        - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. redefineObj - XmlSchemaInclude that will be serialized.
+     * schema - Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element object representation of XmlSchemaRedefine
+     * Return: Element object representation of XmlSchemaRedefine
      * **********************************************************************
      */
-    Element serializeRedefine(Document doc, XmlSchemaRedefine redefineObj,
-                              XmlSchema schema) throws XmlSchemaSerializerException {
+    Element serializeRedefine(Document doc, XmlSchemaRedefine redefineObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
 
-        Element redefine = createNewElement(doc, "redefine",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element redefine = createNewElement(doc, "redefine", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
-        if (redefineObj.schemaLocation != null)
-            redefine.setAttribute("schemaLocation",
-                    redefineObj.schemaLocation);
-        else
-            throw new XmlSchemaSerializerException("redefine must have "
-                    + "schemaLocation fields fill");
+        if (redefineObj.schemaLocation != null) {
+            redefine.setAttribute("schemaLocation", redefineObj.schemaLocation);
+        } else {
+            throw new XmlSchemaSerializerException("redefine must have " + "schemaLocation fields fill");
+        }
 
-        if (redefineObj.id != null)
+        if (redefineObj.id != null) {
             redefine.setAttribute("id", redefineObj.id);
+        }
 
         if (redefineObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc,
-                    redefineObj.annotation, schema);
+            Element annotation = serializeAnnotation(doc, redefineObj.annotation, schema);
             redefine.appendChild(annotation);
         }
         int itemsLength = redefineObj.items.getCount();
         for (int i = 0; i < itemsLength; i++) {
             XmlSchemaObject obj = redefineObj.items.getItem(i);
             if (obj instanceof XmlSchemaSimpleType) {
-                Element simpleType = serializeSimpleType(doc,
-                        (XmlSchemaSimpleType) obj, schema);
+                Element simpleType = serializeSimpleType(doc, (XmlSchemaSimpleType)obj, schema);
                 redefine.appendChild(simpleType);
             } else if (obj instanceof XmlSchemaComplexType) {
-                Element complexType = serializeComplexType(doc,
-                        (XmlSchemaComplexType) obj, schema);
+                Element complexType = serializeComplexType(doc, (XmlSchemaComplexType)obj, schema);
                 redefine.appendChild(complexType);
             } else if (obj instanceof XmlSchemaGroupRef) {
-                Element groupRef = serializeGroupRef(doc,
-                        (XmlSchemaGroupRef) obj, schema);
+                Element groupRef = serializeGroupRef(doc, (XmlSchemaGroupRef)obj, schema);
                 redefine.appendChild(groupRef);
             } else if (obj instanceof XmlSchemaGroup) {
-                Element group = serializeGroup(doc,
-                        (XmlSchemaGroup) obj, schema);
+                Element group = serializeGroup(doc, (XmlSchemaGroup)obj, schema);
                 redefine.appendChild(group);
             } else if (obj instanceof XmlSchemaAttributeGroup) {
-                Element attributeGroup = serializeAttributeGroup(doc,
-                        (XmlSchemaAttributeGroup) obj, schema);
+                Element attributeGroup = serializeAttributeGroup(doc, (XmlSchemaAttributeGroup)obj, schema);
                 redefine.appendChild(attributeGroup);
             } else if (obj instanceof XmlSchemaAttributeGroupRef) {
-                Element attributeGroupRef = serializeAttributeGroupRef(doc,
-                        (XmlSchemaAttributeGroupRef) obj, schema);
+                Element attributeGroupRef = serializeAttributeGroupRef(doc, (XmlSchemaAttributeGroupRef)obj,
+                                                                       schema);
                 redefine.appendChild(attributeGroupRef);
             }
         }
 
-            //process extension
-        processExtensibilityComponents(redefineObj,redefine);
+        // process extension
+        processExtensibilityComponents(redefineObj, redefine);
 
         return redefine;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeElement(Document doc, XmlSchemaElement elementObj,
-     * XmlSchema schema) throws XmlSchemaSerializerException
-     * <p/>
-     * Each member of Element will be appended and pass the element
-     * created.  Element processed according to w3c Recommendation
-     * May 2 2001.
-     * <p/>
-     * Parameter:
-     * doc           - Document the parent use.
-     * elementObj   - XmlSchemaInclude that will be serialized.
-     * schema        - Schema Document object of the parent.
-     * <p/>
-     * Return:
-     * Element object of element.
-     * **********************************************************************
-     */
-    Element serializeElement(Document doc, XmlSchemaElement elementObj,
-                             XmlSchema schema) throws XmlSchemaSerializerException {
-        Element serializedEl = createNewElement(doc, "element",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
-
+     * ********************************************************************* Element serializeElement(Document
+     * doc, XmlSchemaElement elementObj, XmlSchema schema) throws XmlSchemaSerializerException
+     * <p/>
+     * Each member of Element will be appended and pass the element created. Element processed according to
+     * w3c Recommendation May 2 2001.
+     * <p/>
+     * Parameter: doc - Document the parent use. elementObj - XmlSchemaInclude that will be serialized. schema
+     * - Schema Document object of the parent.
+     * <p/>
+     * Return: Element object of element.
+     * **********************************************************************
+     */
+    Element serializeElement(Document doc, XmlSchemaElement elementObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
+        Element serializedEl = createNewElement(doc, "element", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
         if (elementObj.refName != null) {
 
             String resolvedName = resolveQName(elementObj.refName, schema);
             serializedEl.setAttribute("ref", resolvedName);
         } else if (elementObj.name != null && elementObj.name.length() > 0) {
-            serializedEl.setAttribute("name",
-                    elementObj.name);
+            serializedEl.setAttribute("name", elementObj.name);
         }
 
-        if (elementObj.isAbstract)
+        if (elementObj.isAbstract) {
             serializedEl.setAttribute("abstract", "true");
+        }
 
         String block = elementObj.block.getValue();
         if (!block.equals(Constants.BlockConstants.NONE)) {
             block = convertString(block);
             serializedEl.setAttribute("block", block);
         }
-        if (elementObj.defaultValue != null)
-            serializedEl.setAttribute("default",
-                    elementObj.defaultValue);
+        if (elementObj.defaultValue != null) {
+            serializedEl.setAttribute("default", elementObj.defaultValue);
+        }
 
         String finalDerivation = elementObj.finalDerivation.getValue();
         if (!finalDerivation.equals(Constants.BlockConstants.NONE)) {
             finalDerivation = convertString(finalDerivation);
-            serializedEl.setAttribute("final",
-                    finalDerivation);
+            serializedEl.setAttribute("final", finalDerivation);
+        }
+        if (elementObj.fixedValue != null) {
+            serializedEl.setAttribute("fixed", elementObj.fixedValue);
         }
-        if (elementObj.fixedValue != null)
-            serializedEl.setAttribute("fixed",
-                    elementObj.fixedValue);
 
         String formDef = elementObj.form.getValue();
         if (!formDef.equals(XmlSchemaForm.NONE)) {
             formDef = convertString(formDef);
             serializedEl.setAttribute("form", formDef);
         }
-        if (elementObj.id != null)
+        if (elementObj.id != null) {
             serializedEl.setAttribute("id", elementObj.id);
+        }
 
-        
         serializeMaxMinOccurs(elementObj, serializedEl);
-        
-        
+
         if (elementObj.substitutionGroup != null) {
             String resolvedQName = resolveQName(elementObj.substitutionGroup, schema);
-            serializedEl.setAttribute("substitutionGroup",
-                    resolvedQName);
+            serializedEl.setAttribute("substitutionGroup", resolvedQName);
         }
         if (elementObj.schemaTypeName != null) {
             String resolvedName = resolveQName(elementObj.schemaTypeName, schema);
             serializedEl.setAttribute("type", resolvedName);
         }
         if (elementObj.annotation != null) {
-            Element annotationEl = serializeAnnotation(doc,
-                    elementObj.annotation, schema);
+            Element annotationEl = serializeAnnotation(doc, elementObj.annotation, schema);
             serializedEl.appendChild(annotationEl);
         }
         if (elementObj.schemaType != null && elementObj.schemaTypeName == null) {
             if (elementObj.schemaType instanceof XmlSchemaComplexType) {
 
-                Element complexType = serializeComplexType(doc,
-                        (XmlSchemaComplexType) elementObj.schemaType, schema);
+                Element complexType = serializeComplexType(doc, (XmlSchemaComplexType)elementObj.schemaType,
+                                                           schema);
                 serializedEl.appendChild(complexType);
             } else if (elementObj.schemaType instanceof XmlSchemaSimpleType) {
-                Element simpleType = serializeSimpleType(doc,
-                        (XmlSchemaSimpleType) elementObj.schemaType, schema);
+                Element simpleType = serializeSimpleType(doc, (XmlSchemaSimpleType)elementObj.schemaType,
+                                                         schema);
                 serializedEl.appendChild(simpleType);
             }
         }
         if (elementObj.constraints.getCount() > 0) {
             for (int i = 0; i < elementObj.constraints.getCount(); i++) {
-                Element constraint = serializeIdentityConstraint(doc,
-                        (XmlSchemaIdentityConstraint) elementObj.constraints.getItem(i),
-                        schema);
+                Element constraint = serializeIdentityConstraint(
+                                                                 doc,
+                                                                 (XmlSchemaIdentityConstraint)elementObj.constraints
+                                                                     .getItem(i), schema);
                 serializedEl.appendChild(constraint);
             }
         }
@@ -627,37 +572,31 @@
             serializedEl.setAttribute("nillable", "true");
         }
 
-            //process extension
-        processExtensibilityComponents(elementObj,serializedEl);
+        // process extension
+        processExtensibilityComponents(elementObj, serializedEl);
 
         return serializedEl;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeSimpleType(Document doc,
-     * XmlSchemaSimpleType simpleTypeObj, XmlSchema schema)
-     * throws XmlSchemaSerializerException{
+     * ********************************************************************* Element
+     * serializeSimpleType(Document doc, XmlSchemaSimpleType simpleTypeObj, XmlSchema schema) throws
+     * XmlSchemaSerializerException{
      * <p/>
-     * Each member of simple type will be appended and pass the element
-     * created.  Simple type processed according to w3c Recommendation
-     * May 2 2001.
+     * Each member of simple type will be appended and pass the element created. Simple type processed
+     * according to w3c Recommendation May 2 2001.
      * <p/>
-     * Parameter:
-     * doc               - Document the parent use.
-     * simpleTypeObj     - XmlSchemaSimpleType that will be serialized.
-     * schema            - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. simpleTypeObj - XmlSchemaSimpleType that will be serialized.
+     * schema - Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element object of SimpleType
+     * Return: Element object of SimpleType
      * **********************************************************************
      */
-    Element serializeSimpleType(Document doc, XmlSchemaSimpleType simpleTypeObj,
-                                XmlSchema schema) throws XmlSchemaSerializerException {
-
-        Element serializedSimpleType = createNewElement(doc, "simpleType",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+    Element serializeSimpleType(Document doc, XmlSchemaSimpleType simpleTypeObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
 
+        Element serializedSimpleType = createNewElement(doc, "simpleType", schema.schema_ns_prefix,
+                                                        XmlSchema.SCHEMA_NS);
 
         String tmp;
         tmp = simpleTypeObj.finalDerivation.getValue();
@@ -666,344 +605,303 @@
             tmp = convertString(tmp);
             serializedSimpleType.setAttribute("final", tmp);
         }
-        if (simpleTypeObj.id != null)
-            serializedSimpleType.setAttribute("id",
-                    simpleTypeObj.id);
-        if ((simpleTypeObj.name != null) && (!simpleTypeObj.name.equals("")))
-            serializedSimpleType.setAttribute("name",
-                    simpleTypeObj.name);
+        if (simpleTypeObj.id != null) {
+            serializedSimpleType.setAttribute("id", simpleTypeObj.id);
+        }
+        if (simpleTypeObj.name != null && !simpleTypeObj.name.equals("")) {
+            serializedSimpleType.setAttribute("name", simpleTypeObj.name);
+        }
         if (simpleTypeObj.annotation != null) {
-            Element annotationEl = serializeAnnotation(doc,
-                    simpleTypeObj.annotation, schema);
+            Element annotationEl = serializeAnnotation(doc, simpleTypeObj.annotation, schema);
             serializedSimpleType.appendChild(annotationEl);
         }
         if (simpleTypeObj.content != null) {
             if (simpleTypeObj.content instanceof XmlSchemaSimpleTypeRestriction) {
-                Element restEl = serializeSimpleTypeRestriction(doc,
-                        (XmlSchemaSimpleTypeRestriction) simpleTypeObj.content,
-                        schema);
+                Element restEl = serializeSimpleTypeRestriction(
+                                                                doc,
+                                                                (XmlSchemaSimpleTypeRestriction)simpleTypeObj.content,
+                                                                schema);
                 serializedSimpleType.appendChild(restEl);
             } else if (simpleTypeObj.content instanceof XmlSchemaSimpleTypeList) {
-                Element listEl = serializeSimpleTypeList(doc,
-                        (XmlSchemaSimpleTypeList) simpleTypeObj.content, schema);
+                Element listEl = serializeSimpleTypeList(doc, (XmlSchemaSimpleTypeList)simpleTypeObj.content,
+                                                         schema);
                 serializedSimpleType.appendChild(listEl);
             } else if (simpleTypeObj.content instanceof XmlSchemaSimpleTypeUnion) {
                 Element unionEl = serializeSimpleTypeUnion(doc,
-                        (XmlSchemaSimpleTypeUnion) simpleTypeObj.content, schema);
+                                                           (XmlSchemaSimpleTypeUnion)simpleTypeObj.content,
+                                                           schema);
                 serializedSimpleType.appendChild(unionEl);
-            }/*else 
-			   throw new XmlSchemaSerializerException("Invalid type inserted "
-			   + "in simpleType content, the content is: " 
-			   + simpleTypeObj.content.getClass().getName()
-			   + " valid content should be XmlSchemaSimpleTypeunion, "
-			   + "XmlSchemaSimpleTyperestriction or list");*/
-        }/*else
-		   throw new XmlSchemaSerializerException("simple type must be set "
-		   + "with content, either union, restriction or list");*/
+            }/*
+              * else throw new XmlSchemaSerializerException("Invalid type inserted " +
+              * "in simpleType content, the content is: " + simpleTypeObj.content.getClass().getName() +
+              * " valid content should be XmlSchemaSimpleTypeunion, " +
+              * "XmlSchemaSimpleTyperestriction or list");
+              */
+        }/*
+          * else throw new XmlSchemaSerializerException("simple type must be set " +
+          * "with content, either union, restriction or list");
+          */
 
-            //process extension
-        processExtensibilityComponents(simpleTypeObj,serializedSimpleType);
+        // process extension
+        processExtensibilityComponents(simpleTypeObj, serializedSimpleType);
 
         return serializedSimpleType;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeSimpleTypeRestriction(Document doc,
-     * XmlSchemaSimpleTypeRestriction restrictionObj, XmlSchema schema)
-     * throws XmlSchemaSerializerException{
+     * ********************************************************************* Element
+     * serializeSimpleTypeRestriction(Document doc, XmlSchemaSimpleTypeRestriction restrictionObj, XmlSchema
+     * schema) throws XmlSchemaSerializerException{
      * <p/>
-     * Each member of simple type will be appended and pass the element
-     * created.  Simple type's <restriction> processed according to w3c
-     * Recommendation May 2 2001.
-     * <p/>
-     * Parameter:
-     * doc               - Document the parent use.
-     * restrictionObj    - XmlSchemaRestriction that will be serialized.
-     * schema            - Schema Document object of the parent.
-     * <p/>
-     * Return:
-     * Element of simple type restriction and its child.
-     * **********************************************************************
-     */
-    Element serializeSimpleTypeRestriction(Document doc,
-                                           XmlSchemaSimpleTypeRestriction restrictionObj, XmlSchema schema)
-            throws XmlSchemaSerializerException {
-        //todo: need to implement any attribute that related to non schema namespace
-        Element serializedRestriction = createNewElement(doc, "restriction",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+     * Each member of simple type will be appended and pass the element created. Simple type's <restriction>
+     * processed according to w3c Recommendation May 2 2001.
+     * <p/>
+     * Parameter: doc - Document the parent use. restrictionObj - XmlSchemaRestriction that will be
+     * serialized. schema - Schema Document object of the parent.
+     * <p/>
+     * Return: Element of simple type restriction and its child.
+     * **********************************************************************
+     */
+    Element serializeSimpleTypeRestriction(Document doc, XmlSchemaSimpleTypeRestriction restrictionObj,
+                                           XmlSchema schema) throws XmlSchemaSerializerException {
+        // todo: need to implement any attribute that related to non schema namespace
+        Element serializedRestriction = createNewElement(doc, "restriction", schema.schema_ns_prefix,
+                                                         XmlSchema.SCHEMA_NS);
 
-        if (schema.schema_ns_prefix.length() > 0)
+        if (schema.schema_ns_prefix.length() > 0) {
             serializedRestriction.setPrefix(schema.schema_ns_prefix);
+        }
         if (restrictionObj.baseTypeName != null) {
             String baseType = resolveQName(restrictionObj.baseTypeName, schema);
             serializedRestriction.setAttribute("base", baseType);
-        } else if (restrictionObj.baseType != null && restrictionObj.baseType
-                instanceof XmlSchemaSimpleType) {
-            Element inlineSimpleType = serializeSimpleType(doc,
-                    restrictionObj.baseType, schema);
+        } else if (restrictionObj.baseType != null && restrictionObj.baseType instanceof XmlSchemaSimpleType) {
+            Element inlineSimpleType = serializeSimpleType(doc, restrictionObj.baseType, schema);
             serializedRestriction.appendChild(inlineSimpleType);
-        } else
+        } else {
             throw new XmlSchemaSerializerException("restriction must be define "
-                    + "with specifying base or inline simpleType");
+                                                   + "with specifying base or inline simpleType");
+        }
 
-        if (restrictionObj.id != null)
-            serializedRestriction.setAttribute("id",
-                    restrictionObj.id);
+        if (restrictionObj.id != null) {
+            serializedRestriction.setAttribute("id", restrictionObj.id);
+        }
 
         if (restrictionObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc,
-                    restrictionObj.annotation, schema);
+            Element annotation = serializeAnnotation(doc, restrictionObj.annotation, schema);
             serializedRestriction.appendChild(annotation);
         }
         if (restrictionObj.facets.getCount() > 0) {
             int facetsNum = restrictionObj.facets.getCount();
             for (int i = 0; i < facetsNum; i++) {
-                Element facetEl = serializeFacet(doc,
-                        (XmlSchemaFacet) restrictionObj.facets.getItem(i), schema);
+                Element facetEl = serializeFacet(doc, (XmlSchemaFacet)restrictionObj.facets.getItem(i),
+                                                 schema);
                 serializedRestriction.appendChild(facetEl);
             }
         }
 
-            //process extension
-        processExtensibilityComponents(restrictionObj,serializedRestriction);
+        // process extension
+        processExtensibilityComponents(restrictionObj, serializedRestriction);
 
         return serializedRestriction;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeFacet(Document doc, XmlSchemaFacet facetObj,
-     * XmlSchema schema) throws XmlSchemaSerializerException{
+     * ********************************************************************* Element serializeFacet(Document
+     * doc, XmlSchemaFacet facetObj, XmlSchema schema) throws XmlSchemaSerializerException{
      * <p/>
-     * detect what type of facet and cass appropriatelly,
-     * construct the element and pass it.
+     * detect what type of facet and cass appropriatelly, construct the element and pass it.
      * <p/>
-     * Parameter:
-     * doc       - Document the parent use.
-     * facetObj  - XmlSchemaFacet that will be serialized.
-     * schema    - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. facetObj - XmlSchemaFacet that will be serialized. schema -
+     * Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element of simple type with facet.
+     * Return: Element of simple type with facet.
      * **********************************************************************
      */
-    Element serializeFacet(Document doc, XmlSchemaFacet facetObj,
-                           XmlSchema schema) throws XmlSchemaSerializerException {
+    Element serializeFacet(Document doc, XmlSchemaFacet facetObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
 
         Element serializedFacet;
 
-        if (facetObj instanceof XmlSchemaMinExclusiveFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "minExclusive");
-        else if (facetObj instanceof XmlSchemaMinInclusiveFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "minInclusive");
-        else if (facetObj instanceof XmlSchemaMaxExclusiveFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "maxExclusive");
-        else if (facetObj instanceof XmlSchemaMaxInclusiveFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "maxInclusive");
-        else if (facetObj instanceof XmlSchemaTotalDigitsFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "totalDigits");
-        else if (facetObj instanceof XmlSchemaFractionDigitsFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "fractionDigits");
-        else if (facetObj instanceof XmlSchemaLengthFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "length");
-        else if (facetObj instanceof XmlSchemaMinLengthFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "minLength");
-        else if (facetObj instanceof XmlSchemaMaxLengthFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "maxLength");
-        else if (facetObj instanceof XmlSchemaEnumerationFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "enumeration");
-        else if (facetObj instanceof XmlSchemaWhiteSpaceFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "whiteSpace");
-        else if (facetObj instanceof XmlSchemaPatternFacet)
-            serializedFacet = constructFacet(facetObj, doc, schema,
-                    "pattern");
-        else
-            throw new XmlSchemaSerializerException("facet not exist "
-                    + facetObj.getClass().getName());
+        if (facetObj instanceof XmlSchemaMinExclusiveFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "minExclusive");
+        } else if (facetObj instanceof XmlSchemaMinInclusiveFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "minInclusive");
+        } else if (facetObj instanceof XmlSchemaMaxExclusiveFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "maxExclusive");
+        } else if (facetObj instanceof XmlSchemaMaxInclusiveFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "maxInclusive");
+        } else if (facetObj instanceof XmlSchemaTotalDigitsFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "totalDigits");
+        } else if (facetObj instanceof XmlSchemaFractionDigitsFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "fractionDigits");
+        } else if (facetObj instanceof XmlSchemaLengthFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "length");
+        } else if (facetObj instanceof XmlSchemaMinLengthFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "minLength");
+        } else if (facetObj instanceof XmlSchemaMaxLengthFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "maxLength");
+        } else if (facetObj instanceof XmlSchemaEnumerationFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "enumeration");
+        } else if (facetObj instanceof XmlSchemaWhiteSpaceFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "whiteSpace");
+        } else if (facetObj instanceof XmlSchemaPatternFacet) {
+            serializedFacet = constructFacet(facetObj, doc, schema, "pattern");
+        } else {
+            throw new XmlSchemaSerializerException("facet not exist " + facetObj.getClass().getName());
+        }
 
-        if (facetObj.id != null)
+        if (facetObj.id != null) {
             serializedFacet.setAttribute("id", facetObj.id);
-//        if (facetObj.annotation != null) {
-//            Element annotation = serializeAnnotation(doc, facetObj.annotation,
-//                                                     schema);
-//            serializedFacet.appendChild(annotation);
-//        }
+            // if (facetObj.annotation != null) {
+            // Element annotation = serializeAnnotation(doc, facetObj.annotation,
+            // schema);
+            // serializedFacet.appendChild(annotation);
+            // }
+        }
 
-            //process extension
-        processExtensibilityComponents(facetObj,serializedFacet);
+        // process extension
+        processExtensibilityComponents(facetObj, serializedFacet);
 
         return serializedFacet;
     }
 
-    private Element constructFacet(XmlSchemaFacet facetObj, Document doc,
-                                   XmlSchema schema, String tagName) {
+    private Element constructFacet(XmlSchemaFacet facetObj, Document doc, XmlSchema schema, String tagName) {
 
-        Element facetEl = createNewElement(doc, tagName,
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element facetEl = createNewElement(doc, tagName, schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
-        facetEl.setAttribute("value",
-                facetObj.value.toString());
-        if (facetObj.fixed)
+        facetEl.setAttribute("value", facetObj.value.toString());
+        if (facetObj.fixed) {
             facetEl.setAttribute("fixed", "true");
+        }
 
         if (facetObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc,
-                    facetObj.annotation, schema);
+            Element annotation = serializeAnnotation(doc, facetObj.annotation, schema);
             facetEl.appendChild(annotation);
         }
         return facetEl;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeComplexType(Document doc,
-     * XmlSchemaComplexType complexTypeObj, XmlSchema schema)
-     * throws XmlSchemaSerializerException{
+     * ********************************************************************* Element
+     * serializeComplexType(Document doc, XmlSchemaComplexType complexTypeObj, XmlSchema schema) throws
+     * XmlSchemaSerializerException{
+     * <p/>
+     * Each member of complex type will be appended and pass the element created. Complex type processed
+     * according to w3c Recommendation May 2 2001.
+     * <p/>
+     * Parameter: doc - Document the parent use. complexTypeObj - XmlSchemaFacet that will be serialized.
+     * schema - Schema Document object of the parent.
      * <p/>
-     * Each member of complex type will be appended and pass the element
-     * created.  Complex type processed according to w3c Recommendation
-     * May 2 2001.
-     * <p/>
-     * Parameter:
-     * doc             - Document the parent use.
-     * complexTypeObj  - XmlSchemaFacet that will be serialized.
-     * schema          - Schema Document object of the parent.
-     * <p/>
-     * Return:
-     * Element of complexType.
-     * **********************************************************************
-     */
-    Element serializeComplexType(Document doc,
-                                 XmlSchemaComplexType complexTypeObj, XmlSchema schema)
-            throws XmlSchemaSerializerException {
-
-        //todo: need to implement abstract, id, mixed
-        Element serializedComplexType = createNewElement(doc,
-                "complexType", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
-
-        if ((complexTypeObj.name != null) && (!complexTypeObj.name.equals("")))
-            serializedComplexType.setAttribute("name",
-                    complexTypeObj.name);
-        /*if(complexTypeObj.annotation != null){
-		  Element annotationEl = serializeAnnotation(doc, 
-		  complexTypeObj.annotation, schema);
-		  serializedComplexType.appendChild(annotationEl);
-		  }*/
+     * Return: Element of complexType. **********************************************************************
+     */
+    Element serializeComplexType(Document doc, XmlSchemaComplexType complexTypeObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
+
+        // todo: need to implement abstract, id, mixed
+        Element serializedComplexType = createNewElement(doc, "complexType", schema.schema_ns_prefix,
+                                                         XmlSchema.SCHEMA_NS);
+
+        if (complexTypeObj.name != null && !complexTypeObj.name.equals("")) {
+            serializedComplexType.setAttribute("name", complexTypeObj.name);
+            /*
+             * if(complexTypeObj.annotation != null){ Element annotationEl = serializeAnnotation(doc,
+             * complexTypeObj.annotation, schema); serializedComplexType.appendChild(annotationEl); }
+             */
+        }
 
-        if (complexTypeObj.isMixed)
+        if (complexTypeObj.isMixed) {
             serializedComplexType.setAttribute("mixed", "true");
-        if (complexTypeObj.isAbstract)
-            serializedComplexType.setAttribute(
-                    "abstract", "true");
-        if (complexTypeObj.id != null)
-            serializedComplexType.setAttribute("id",
-                    complexTypeObj.id);
-        
+        }
+        if (complexTypeObj.isAbstract) {
+            serializedComplexType.setAttribute("abstract", "true");
+        }
+        if (complexTypeObj.id != null) {
+            serializedComplexType.setAttribute("id", complexTypeObj.id);
+        }
+
         if (complexTypeObj.annotation != null) {
-            Element annotationEl = serializeAnnotation(doc,
-                    complexTypeObj.annotation, schema);
+            Element annotationEl = serializeAnnotation(doc, complexTypeObj.annotation, schema);
             serializedComplexType.appendChild(annotationEl);
         }
 
         if (complexTypeObj.contentModel instanceof XmlSchemaSimpleContent) {
-            Element simpleContent = serializeSimpleContent(doc,
-                    (XmlSchemaSimpleContent) complexTypeObj.contentModel, schema);
+            Element simpleContent = serializeSimpleContent(
+                                                           doc,
+                                                           (XmlSchemaSimpleContent)complexTypeObj.contentModel,
+                                                           schema);
             serializedComplexType.appendChild(simpleContent);
-        } else if (complexTypeObj.contentModel instanceof
-                XmlSchemaComplexContent) {
+        } else if (complexTypeObj.contentModel instanceof XmlSchemaComplexContent) {
 
-            Element complexContent = serializeComplexContent(doc,
-                    (XmlSchemaComplexContent) complexTypeObj.contentModel, schema);
+            Element complexContent = serializeComplexContent(
+                                                             doc,
+                                                             (XmlSchemaComplexContent)complexTypeObj.contentModel,
+                                                             schema);
             serializedComplexType.appendChild(complexContent);
         }
 
         if (complexTypeObj.particle instanceof XmlSchemaSequence) {
-            Element sequence = serializeSequence(doc,
-                    (XmlSchemaSequence) complexTypeObj.particle, schema);
+            Element sequence = serializeSequence(doc, (XmlSchemaSequence)complexTypeObj.particle, schema);
             serializedComplexType.appendChild(sequence);
         } else if (complexTypeObj.particle instanceof XmlSchemaChoice) {
-            Element choice = serializeChoice(doc,
-                    (XmlSchemaChoice) complexTypeObj.particle, schema);
+            Element choice = serializeChoice(doc, (XmlSchemaChoice)complexTypeObj.particle, schema);
             serializedComplexType.appendChild(choice);
         } else if (complexTypeObj.particle instanceof XmlSchemaAll) {
-            Element all = serializeAll(doc,
-                    (XmlSchemaAll) complexTypeObj.particle, schema);
+            Element all = serializeAll(doc, (XmlSchemaAll)complexTypeObj.particle, schema);
             serializedComplexType.appendChild(all);
         } else if (complexTypeObj.particle instanceof XmlSchemaGroupRef) {
-            Element group = serializeGroupRef(doc,
-                    (XmlSchemaGroupRef) complexTypeObj.particle, schema);
+            Element group = serializeGroupRef(doc, (XmlSchemaGroupRef)complexTypeObj.particle, schema);
             serializedComplexType.appendChild(group);
         }
 
         String block = complexTypeObj.block.getValue();
         if (!block.equals(Constants.BlockConstants.NONE)) {
             block = convertString(block);
-            serializedComplexType.setAttribute(
-                    "block", block);
+            serializedComplexType.setAttribute("block", block);
         }
         String finalDerivation = complexTypeObj.finalDerivation.getValue();
         if (!finalDerivation.equals(Constants.BlockConstants.NONE)) {
             finalDerivation = convertString(finalDerivation);
-            serializedComplexType.setAttribute("final",
-                    finalDerivation);
+            serializedComplexType.setAttribute("final", finalDerivation);
         }
 
         XmlSchemaObjectCollection attrColl = complexTypeObj.attributes;
-        if (attrColl.getCount() > 0)
+        if (attrColl.getCount() > 0) {
             setupAttr(doc, attrColl, schema, serializedComplexType);
-        
+        }
+
         XmlSchemaAnyAttribute anyAttribute = complexTypeObj.getAnyAttribute();
-        if(anyAttribute != null) {
-        	serializedComplexType.appendChild(serializeAnyAttribute(doc, anyAttribute, schema));
+        if (anyAttribute != null) {
+            serializedComplexType.appendChild(serializeAnyAttribute(doc, anyAttribute, schema));
         }
-        
 
-            //process extension
-        processExtensibilityComponents(complexTypeObj,serializedComplexType);
+        // process extension
+        processExtensibilityComponents(complexTypeObj, serializedComplexType);
 
         return serializedComplexType;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeSequence(Document doc, XmlSchemaSequence sequenceObj,
-     * XmlSchema schema)throws XmlSchemaSerializerException{
+     * ********************************************************************* Element
+     * serializeSequence(Document doc, XmlSchemaSequence sequenceObj, XmlSchema schema)throws
+     * XmlSchemaSerializerException{
      * <p/>
-     * Each member of complex type will be appended and pass the element
-     * created.  `Complex type processed according to w3c Recommendation
-     * May 2 2001.
+     * Each member of complex type will be appended and pass the element created. `Complex type processed
+     * according to w3c Recommendation May 2 2001.
      * <p/>
-     * Parameter:
-     * doc             - Document the parent use.
-     * sequenceObj  - XmlSchemaFacet that will be serialized.
-     * schema          - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. sequenceObj - XmlSchemaFacet that will be serialized. schema
+     * - Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element of sequence particle.
+     * Return: Element of sequence particle.
      * **********************************************************************
      */
-    Element serializeSequence(Document doc, XmlSchemaSequence sequenceObj,
-                              XmlSchema schema) throws XmlSchemaSerializerException {
+    Element serializeSequence(Document doc, XmlSchemaSequence sequenceObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
 
-        Element sequence = createNewElement(doc, "sequence",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element sequence = createNewElement(doc, "sequence", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
-
-        if (sequenceObj.id != null)
+        if (sequenceObj.id != null) {
             sequence.setAttribute("id", sequenceObj.id);
-
+        }
 
         serializeMaxMinOccurs(sequenceObj, sequence);
 
@@ -1012,107 +910,94 @@
         for (int i = 0; i < containLength; i++) {
             XmlSchemaObject obj = seqColl.getItem(i);
             if (obj instanceof XmlSchemaElement) {
-                Element el = serializeElement(doc,
-                        (XmlSchemaElement) obj, schema);
+                Element el = serializeElement(doc, (XmlSchemaElement)obj, schema);
                 sequence.appendChild(el);
             } else if (obj instanceof XmlSchemaGroupRef) {
-                Element group = serializeGroupRef(doc,
-                        (XmlSchemaGroupRef) obj, schema);
+                Element group = serializeGroupRef(doc, (XmlSchemaGroupRef)obj, schema);
                 sequence.appendChild(group);
             } else if (obj instanceof XmlSchemaChoice) {
-                Element choice = serializeChoice(doc,
-                        (XmlSchemaChoice) obj, schema);
+                Element choice = serializeChoice(doc, (XmlSchemaChoice)obj, schema);
                 sequence.appendChild(choice);
             } else if (obj instanceof XmlSchemaSequence) {
-                Element sequenceChild = serializeSequence(doc,
-                        (XmlSchemaSequence) obj, schema);
+                Element sequenceChild = serializeSequence(doc, (XmlSchemaSequence)obj, schema);
                 sequence.appendChild(sequenceChild);
             } else if (obj instanceof XmlSchemaAny) {
-                Element any = serializeAny(doc, (XmlSchemaAny) obj, schema);
+                Element any = serializeAny(doc, (XmlSchemaAny)obj, schema);
                 sequence.appendChild(any);
             }
         }
 
-            //process extension
-        processExtensibilityComponents(sequenceObj,sequence);
+        // process extension
+        processExtensibilityComponents(sequenceObj, sequence);
 
         return sequence;
     }
 
     /**
      * A common method to serialize the max/min occurs
+     * 
      * @param particle
      * @param element
      */
-	private void serializeMaxMinOccurs(XmlSchemaParticle particle,
-			Element element) {
-		if (particle.maxOccurs < Long.MAX_VALUE &&
-                (particle.maxOccurs > 1 || particle.maxOccurs == 0))
-            element.setAttribute("maxOccurs",
-                    particle.maxOccurs + "");
-        else if (particle.maxOccurs == Long.MAX_VALUE)
-            element.setAttribute("maxOccurs",
-                    "unbounded");
-        //else not serialized
-
-        //1 is the default and hence not serialized
-        //there is no valid case where min occurs can be unbounded!
-        if (particle.minOccurs > 1 || particle.minOccurs == 0)
-            element.setAttribute("minOccurs",
-                    particle.minOccurs + "");
-	}
+    private void serializeMaxMinOccurs(XmlSchemaParticle particle, Element element) {
+        if (particle.maxOccurs < Long.MAX_VALUE && (particle.maxOccurs > 1 || particle.maxOccurs == 0)) {
+            element.setAttribute("maxOccurs", particle.maxOccurs + "");
+        } else if (particle.maxOccurs == Long.MAX_VALUE) {
+            element.setAttribute("maxOccurs", "unbounded");
+            // else not serialized
+        }
+
+        // 1 is the default and hence not serialized
+        // there is no valid case where min occurs can be unbounded!
+        if (particle.minOccurs > 1 || particle.minOccurs == 0) {
+            element.setAttribute("minOccurs", particle.minOccurs + "");
+        }
+    }
 
     /**
-     * *********************************************************************
-     * Element serializeAttribute(Document doc, XmlSchemaAttribute attributeObj,
-     * XmlSchema schema) throws XmlSchemaSerializerException{
+     * ********************************************************************* Element
+     * serializeAttribute(Document doc, XmlSchemaAttribute attributeObj, XmlSchema schema) throws
+     * XmlSchemaSerializerException{
      * <p/>
-     * Each member of complex type will be appended and pass the element
-     * created.  `Complex type processed according to w3c Recommendation
-     * May 2 2001.
+     * Each member of complex type will be appended and pass the element created. `Complex type processed
+     * according to w3c Recommendation May 2 2001.
      * <p/>
-     * Parameter:
-     * doc             - Document the parent use.
-     * attributeObj    - XmlSchemaAttribute that will be serialized.
-     * schema          - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. attributeObj - XmlSchemaAttribute that will be serialized.
+     * schema - Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element of attribute.
-     * **********************************************************************
+     * Return: Element of attribute. **********************************************************************
      */
-    Element serializeAttribute(Document doc, XmlSchemaAttribute attributeObj,
-                               XmlSchema schema) throws XmlSchemaSerializerException {
+    Element serializeAttribute(Document doc, XmlSchemaAttribute attributeObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
 
-        Element attribute = createNewElement(doc, "attribute",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element attribute = createNewElement(doc, "attribute", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
         if (attributeObj.refName != null) {
-            String refName =
-                    resolveQName(attributeObj.refName, schema);
+            String refName = resolveQName(attributeObj.refName, schema);
             attribute.setAttribute("ref", refName);
-        } else if (attributeObj.name != null)
-            attribute.setAttribute("name",
-                    attributeObj.name);
+        } else if (attributeObj.name != null) {
+            attribute.setAttribute("name", attributeObj.name);
+        }
 
         if (attributeObj.schemaTypeName != null) {
-            String typeName =
-                    resolveQName(attributeObj.schemaTypeName, schema);
+            String typeName = resolveQName(attributeObj.schemaTypeName, schema);
             attribute.setAttribute("type", typeName);
         }
 
-        if (attributeObj.defaultValue != null)
-            attribute.setAttribute("default",
-                    attributeObj.defaultValue);
-        if (attributeObj.fixedValue != null)
-            attribute.setAttribute("fixed",
-                    attributeObj.fixedValue);
+        if (attributeObj.defaultValue != null) {
+            attribute.setAttribute("default", attributeObj.defaultValue);
+        }
+        if (attributeObj.fixedValue != null) {
+            attribute.setAttribute("fixed", attributeObj.fixedValue);
+        }
 
         String formType = attributeObj.form.getValue();
         if (!formType.equals(XmlSchemaForm.NONE)) {
             formType = convertString(formType);
             attribute.setAttribute("form", formType);
         }
-        if (attributeObj.id != null)
+        if (attributeObj.id != null) {
             attribute.setAttribute("id", attributeObj.id);
+        }
 
         String useType = attributeObj.use.getValue();
         if (!useType.equals(Constants.BlockConstants.NONE)) {
@@ -1120,21 +1005,18 @@
             attribute.setAttribute("use", useType);
         }
         if (attributeObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc,
-                    attributeObj.annotation, schema);
+            Element annotation = serializeAnnotation(doc, attributeObj.annotation, schema);
             attribute.appendChild(annotation);
         }
 
-
         if (attributeObj.schemaType != null) {
             try {
-                XmlSchemaSimpleType simpleType =
-                        attributeObj.schemaType;
-                Element simpleTypeEl = serializeSimpleType(doc,
-                        simpleType, schema);
+                XmlSchemaSimpleType simpleType = attributeObj.schemaType;
+                Element simpleTypeEl = serializeSimpleType(doc, simpleType, schema);
                 attribute.appendChild(simpleTypeEl);
             } catch (ClassCastException e) {
-                throw new XmlSchemaSerializerException("only inline simple type allow as attribute's inline type");
+                throw new XmlSchemaSerializerException(
+                                                       "only inline simple type allow as attribute's inline type");
             }
         }
 
@@ -1144,16 +1026,16 @@
 
         if (unhandled != null) {
 
-            // this is to make the wsdl:arrayType work 
+            // this is to make the wsdl:arrayType work
             // since unhandles attributes are not handled this is a special case
             // but the basic idea is to see if there is any attibute whose value has ":"
             // if it is present then it is likely that it is a namespace prefix
-            // do what is neccesary to get the real namespace for it and make 
-            // required changes to the prefix 
+            // do what is neccesary to get the real namespace for it and make
+            // required changes to the prefix
 
-            for (int i = 0; i < unhandled.length; i++) {
-                String name = unhandled[i].getNodeName();
-                String value = unhandled[i].getNodeValue();
+            for (Attr element : unhandled) {
+                String name = element.getNodeName();
+                String value = element.getNodeValue();
                 if (name.equals("xmlns")) {
                     namespaces.put("", value);
                 } else if (name.startsWith("xmlns")) {
@@ -1161,18 +1043,17 @@
                 }
             }
 
-            for (int i = 0; i < unhandled.length; i++) {
-                String value = unhandled[i].getNodeValue();
-                String nodeName = unhandled[i].getNodeName();
+            for (Attr element : unhandled) {
+                String value = element.getNodeValue();
+                String nodeName = element.getNodeName();
                 if (value.indexOf(":") > -1 && !nodeName.startsWith("xmlns")) {
                     String prefix = value.substring(0, value.indexOf(":"));
                     String oldNamespace;
-                    if ((oldNamespace = (String) namespaces.get(prefix)) != null) {
+                    if ((oldNamespace = (String)namespaces.get(prefix)) != null) {
                         value = value.substring(value.indexOf(":") + 1);
                         NamespacePrefixList ctx = schema.getNamespaceContext();
                         String[] prefixes = ctx.getDeclaredPrefixes();
-                        for (int j = 0;  j < prefixes.length;  j++) {
-                            String pref = prefixes[j];
+                        for (String pref : prefixes) {
                             String uri = ctx.getNamespaceURI(pref);
                             if (uri.equals(oldNamespace)) {
                                 value = prefix + ":" + value;
@@ -1181,68 +1062,56 @@
                     }
 
                 }
-                if (unhandled[i].getNamespaceURI() != null)
-                    attribute.setAttributeNS(unhandled[i].getNamespaceURI(), nodeName, value);
-                else
+                if (element.getNamespaceURI() != null) {
+                    attribute.setAttributeNS(element.getNamespaceURI(), nodeName, value);
+                } else {
                     attribute.setAttribute(nodeName, value);
+                }
             }
         }
 
-            //process extension
-        processExtensibilityComponents(attributeObj,attribute);
+        // process extension
+        processExtensibilityComponents(attributeObj, attribute);
 
         return attribute;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeChoice(Document doc, XmlSchemaChoice choiceObj,
-     * XmlSchema schema) throws XmlSchemaSerializerException{
+     * ********************************************************************* Element serializeChoice(Document
+     * doc, XmlSchemaChoice choiceObj, XmlSchema schema) throws XmlSchemaSerializerException{
      * <p/>
-     * Each member of complex type will be appended and pass the element
-     * created.  Complex type processed according to w3c Recommendation
-     * May 2 2001.
-     * <p/>
-     * Parameter:
-     * doc             - Document the parent use.
-     * choiceObj       - XmlSchemaChoice that will be serialized.
-     * schema          - Schema Document object of the parent.
-     * <p/>
-     * Return:
-     * Element of choice schema object.
-     * **********************************************************************
-     */
-    Element serializeChoice(Document doc, XmlSchemaChoice choiceObj,
-                            XmlSchema schema) throws XmlSchemaSerializerException {
-        //todo: handle any non schema attri ?
-
-        Element choice = createNewElement(doc, "choice",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
-        if (choiceObj.id != null)
-            if (choiceObj.id.length() > 0)
-                choice.setAttribute("id", choiceObj.id);
+     * Each member of complex type will be appended and pass the element created. Complex type processed
+     * according to w3c Recommendation May 2 2001.
+     * <p/>
+     * Parameter: doc - Document the parent use. choiceObj - XmlSchemaChoice that will be serialized. schema -
+     * Schema Document object of the parent.
+     * <p/>
+     * Return: Element of choice schema object.
+     * **********************************************************************
+     */
+    Element serializeChoice(Document doc, XmlSchemaChoice choiceObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
+        // todo: handle any non schema attri ?
 
+        Element choice = createNewElement(doc, "choice", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        if (choiceObj.id != null) {
+            if (choiceObj.id.length() > 0) {
+                choice.setAttribute("id", choiceObj.id);
+            }
+        }
 
         serializeMaxMinOccurs(choiceObj, choice);
 
-
         /*
-            if(choiceObj.maxOccursString != null)
-            choice.setAttribute("maxOccurs",
-            choiceObj.maxOccursString);
-            else if(choiceObj.maxOccurs > 1)
-            choice.setAttribute("maxOccurs",
-            choiceObj.maxOccurs +"");
-          */
-
+         * if(choiceObj.maxOccursString != null) choice.setAttribute("maxOccurs", choiceObj.maxOccursString);
+         * else if(choiceObj.maxOccurs > 1) choice.setAttribute("maxOccurs", choiceObj.maxOccurs +"");
+         */
 
         if (choiceObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc,
-                    choiceObj.annotation, schema);
+            Element annotation = serializeAnnotation(doc, choiceObj.annotation, schema);
             choice.appendChild(annotation);
         }
 
-
         XmlSchemaObjectCollection itemColl = choiceObj.items;
 
         if (itemColl != null) {
@@ -1252,62 +1121,50 @@
                 XmlSchemaObject obj = itemColl.getItem(i);
 
                 if (obj instanceof XmlSchemaElement) {
-                    Element el = serializeElement(doc,
-                            (XmlSchemaElement) obj, schema);
+                    Element el = serializeElement(doc, (XmlSchemaElement)obj, schema);
                     choice.appendChild(el);
                 } else if (obj instanceof XmlSchemaGroupRef) {
-                    Element group = serializeGroupRef(doc,
-                            (XmlSchemaGroupRef) obj, schema);
+                    Element group = serializeGroupRef(doc, (XmlSchemaGroupRef)obj, schema);
                     choice.appendChild(group);
                 } else if (obj instanceof XmlSchemaChoice) {
-                    Element inlineChoice = serializeChoice(doc,
-                            (XmlSchemaChoice) obj, schema);
+                    Element inlineChoice = serializeChoice(doc, (XmlSchemaChoice)obj, schema);
                     choice.appendChild(inlineChoice);
                 } else if (obj instanceof XmlSchemaSequence) {
-                    Element inlineSequence = serializeSequence(doc,
-                            (XmlSchemaSequence) obj, schema);
+                    Element inlineSequence = serializeSequence(doc, (XmlSchemaSequence)obj, schema);
                     choice.appendChild(inlineSequence);
                 } else if (obj instanceof XmlSchemaAny) {
-                    Element any = serializeAny(doc, (XmlSchemaAny) obj, schema);
+                    Element any = serializeAny(doc, (XmlSchemaAny)obj, schema);
                     choice.appendChild(any);
                 }
             }
         }
 
-            //process extension
-        processExtensibilityComponents(choiceObj,choice);
+        // process extension
+        processExtensibilityComponents(choiceObj, choice);
 
         return choice;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeAll(Document doc, XmlSchemaAll allObj, XmlSchema schema)
-     * throws XmlSchemaSerializerException{
+     * ********************************************************************* Element serializeAll(Document
+     * doc, XmlSchemaAll allObj, XmlSchema schema) throws XmlSchemaSerializerException{
      * <p/>
-     * Each member of complex type will be appended and pass the element
-     * created.  Complex type processed according to w3c Recommendation
-     * May 2 2001.
-     * <p/>
-     * Parameter:
-     * doc             - Document the parent use.
-     * allObj          - XmlSchemaAll that will be serialized.
-     * schema          - Schema Document object of the parent.
+     * Each member of complex type will be appended and pass the element created. Complex type processed
+     * according to w3c Recommendation May 2 2001.
      * <p/>
-     * Return:
-     * Element of particle all.
-     * **********************************************************************
+     * Parameter: doc - Document the parent use. allObj - XmlSchemaAll that will be serialized. schema -
+     * Schema Document object of the parent.
+     * <p/>
+     * Return: Element of particle all. **********************************************************************
      */
     Element serializeAll(Document doc, XmlSchemaAll allObj, XmlSchema schema)
-            throws XmlSchemaSerializerException {
-        Element allEl = createNewElement(doc, "all", schema.schema_ns_prefix,
-                XmlSchema.SCHEMA_NS);
+        throws XmlSchemaSerializerException {
+        Element allEl = createNewElement(doc, "all", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
         serializeMaxMinOccurs(allObj, allEl);
 
         if (allObj.annotation != null) {
-            Element annotation = serializeAnnotation(doc, allObj.annotation,
-                    schema);
+            Element annotation = serializeAnnotation(doc, allObj.annotation, schema);
             allEl.appendChild(annotation);
         }
 
@@ -1319,58 +1176,48 @@
             for (int i = 0; i < itemLength; i++) {
                 XmlSchemaObject obj = itemColl.getItem(i);
                 if (obj instanceof XmlSchemaElement) {
-                    Element el = serializeElement(doc, (XmlSchemaElement) obj,
-                            schema);
+                    Element el = serializeElement(doc, (XmlSchemaElement)obj, schema);
                     allEl.appendChild(el);
-                } else
+                } else {
                     throw new XmlSchemaSerializerException("Only element "
-                            + "allowed as child of all model type");
+                                                           + "allowed as child of all model type");
+                }
             }
         }
 
-            //process extension
-        processExtensibilityComponents(allObj,allEl);
+        // process extension
+        processExtensibilityComponents(allObj, allEl);
 
         return allEl;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeSimpleTypeList(Document doc,
-     * XmlSchemaSimpleTypeList listObj, XmlSchema schema)
-     * throws XmlSchemaSerializerException{
+     * ********************************************************************* Element
+     * serializeSimpleTypeList(Document doc, XmlSchemaSimpleTypeList listObj, XmlSchema schema) throws
+     * XmlSchemaSerializerException{
      * <p/>
-     * Each member of complex type will be appended and pass the element
-     * created.  Complex type processed according to w3c Recommendation
-     * May 2 2001.
+     * Each member of complex type will be appended and pass the element created. Complex type processed
+     * according to w3c Recommendation May 2 2001.
      * <p/>
-     * Parameter:
-     * doc             - Document the parent use.
-     * listObj         - XmlSchemaSimpleTypeList that will be serialized.
-     * schema          - Schema Document object of the parent.
+     * Parameter: doc - Document the parent use. listObj - XmlSchemaSimpleTypeList that will be serialized.
+     * schema - Schema Document object of the parent.
      * <p/>
-     * Return:
-     * Element of simple type with list method.
+     * Return: Element of simple type with list method.
      * **********************************************************************
      */
-    Element serializeSimpleTypeList(Document doc,
-                                    XmlSchemaSimpleTypeList listObj, XmlSchema schema)
-            throws XmlSchemaSerializerException {
+    Element serializeSimpleTypeList(Document doc, XmlSchemaSimpleTypeList listObj, XmlSchema schema)
+        throws XmlSchemaSerializerException {
 
-        Element list = createNewElement(doc, "list",
-                schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
+        Element list = createNewElement(doc, "list", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);
 
         if (listObj.itemTypeName != null) {
-            String listItemType = resolveQName(listObj.itemTypeName,
-                    schema);
+            String listItemType = resolveQName(listObj.itemTypeName, schema);
             list.setAttribute("itemType", listItemType);
         }
-        if (listObj.id != null)
+        if (listObj.id != null) {
             list.setAttribute("id", listObj.id);
-
-        else if (listObj.itemType != null) {
-            Element inlineSimpleEl = serializeSimpleType(doc, listObj.itemType,
-                    schema);
+        } else if (listObj.itemType != null) {
+            Element inlineSimpleEl = serializeSimpleType(doc, listObj.itemType, schema);
             list.appendChild(inlineSimpleEl);
         }
         if (listObj.annotation != null) {
@@ -1378,540 +1225,460 @@
             list.appendChild(annotation);
         }
 
-            //process extension
-        processExtensibilityComponents(listObj,list);
+        // process extension
+        processExtensibilityComponents(listObj, list);
 
         return list;
     }
 
     /**
-     * *********************************************************************
-     * Element serializeSimpleTypeUnion(Document doc,
-     * XmlSchemaSimpleTypeUnion unionObj, XmlSchema schema)
-     * throws XmlSchemaSerializerException{
+     * ********************************************************************* Element
+     * serializeSimpleTypeUnion(Document doc, XmlSchemaSimpleTypeUnion unionObj, XmlSchema schema) throws
+     * XmlSchemaSerializerException{
      * <p/>
-     * Each member of complex type will be appended and pass the element
-     * created.  Complex type processed according to w3c Recommendation
-     * May 2 2001.

[... 1849 lines stripped ...]