Merge pull request #185 from QuickJack/master
[mono.git] / mcs / class / System.XML / System.Xml.Schema / XmlSchemaSerializer.cs
1 using System;
2 using System.Xml;
3 using System.Xml.Schema;
4 using System.Xml.Serialization;
5 using System.Text;
6 using System.Collections;
7 using System.Globalization;
8
9 namespace System.Xml.Schema
10 {
11
12         internal class XmlSchemaSerializationWriter : XmlSerializationWriter
13         {
14                 const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
15                 public void WriteRoot_XmlSchema (object o)
16                 {
17                         WriteStartDocument ();
18                         System.Xml.Schema.XmlSchema ob = (System.Xml.Schema.XmlSchema) o;
19                         TopLevelElement ();
20                         WriteObject_XmlSchema (ob, "schema", "http://www.w3.org/2001/XMLSchema", true, false, true);
21                 }
22
23                 void WriteObject_XmlSchema (System.Xml.Schema.XmlSchema ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
24                 {
25                         if (ob == null)
26                         {
27                                 if (isNullable)
28                                         WriteNullTagLiteral(element, namesp);
29                                 return;
30                         }
31
32                         System.Type type = ob.GetType ();
33                         if (type == typeof(System.Xml.Schema.XmlSchema))
34                                 ;
35                         else {
36                                 throw CreateUnknownTypeException (ob);
37                         }
38
39                         if (writeWrappingElem) {
40                                 WriteStartElement (element, namesp, ob);
41                         }
42
43                         if (needType) WriteXsiType("XmlSchema", "http://www.w3.org/2001/XMLSchema");
44
45                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
46
47                         ICollection o0 = ob.@UnhandledAttributes;
48                         if (o0 != null) {
49                                 foreach (XmlAttribute o1 in o0)
50                                         if (o1.NamespaceURI != xmlNamespace)
51                                                 WriteXmlAttribute (o1, ob);
52                         }
53
54                         if (ob.@AttributeFormDefault != ((System.Xml.Schema.XmlSchemaForm) System.Xml.Schema.XmlSchemaForm.None)) {
55                                 WriteAttribute ("attributeFormDefault", "", GetEnumValue_XmlSchemaForm (ob.@AttributeFormDefault));
56                         }
57                         if (ob.@BlockDefault != ((System.Xml.Schema.XmlSchemaDerivationMethod) System.Xml.Schema.XmlSchemaDerivationMethod.None)) {
58                                 WriteAttribute ("blockDefault", "", GetEnumValue_XmlSchemaDerivationMethod (ob.@BlockDefault));
59                         }
60                         if (ob.@FinalDefault != ((System.Xml.Schema.XmlSchemaDerivationMethod) System.Xml.Schema.XmlSchemaDerivationMethod.None)) {
61                                 WriteAttribute ("finalDefault", "", GetEnumValue_XmlSchemaDerivationMethod (ob.@FinalDefault));
62                         }
63                         if (ob.@ElementFormDefault != ((System.Xml.Schema.XmlSchemaForm) System.Xml.Schema.XmlSchemaForm.None)) {
64                                 WriteAttribute ("elementFormDefault", "", GetEnumValue_XmlSchemaForm (ob.@ElementFormDefault));
65                         }
66                         WriteAttribute ("targetNamespace", "", ob.@TargetNamespace);
67                         WriteAttribute ("version", "", ob.@Version);
68                         WriteAttribute ("id", "", ob.@Id);
69
70                         if (ob.@Includes != null) {
71                                 for (int n2 = 0; n2 < ob.@Includes.Count; n2++) {
72                                         if (ob.@Includes[n2] == null) { }
73                                         else if (ob.@Includes[n2].GetType() == typeof(System.Xml.Schema.XmlSchemaInclude)) {
74                                                 WriteObject_XmlSchemaInclude (((System.Xml.Schema.XmlSchemaInclude) ob.@Includes[n2]), "include", "http://www.w3.org/2001/XMLSchema", false, false, true);
75                                         }
76                                         else if (ob.@Includes[n2].GetType() == typeof(System.Xml.Schema.XmlSchemaImport)) {
77                                                 WriteObject_XmlSchemaImport (((System.Xml.Schema.XmlSchemaImport) ob.@Includes[n2]), "import", "http://www.w3.org/2001/XMLSchema", false, false, true);
78                                         }
79                                         else if (ob.@Includes[n2].GetType() == typeof(System.Xml.Schema.XmlSchemaRedefine)) {
80                                                 WriteObject_XmlSchemaRedefine (((System.Xml.Schema.XmlSchemaRedefine) ob.@Includes[n2]), "redefine", "http://www.w3.org/2001/XMLSchema", false, false, true);
81                                         }
82                                         else throw CreateUnknownTypeException (ob.@Includes[n2]);
83                                 }
84                         }
85                         if (ob.@Items != null) {
86                                 for (int n3 = 0; n3 < ob.@Items.Count; n3++) {
87                                         if (ob.@Items[n3] == null) { }
88                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaElement)) {
89                                                 WriteObject_XmlSchemaElement (((System.Xml.Schema.XmlSchemaElement) ob.@Items[n3]), "element", "http://www.w3.org/2001/XMLSchema", false, false, true);
90                                         }
91                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaSimpleType)) {
92                                                 WriteObject_XmlSchemaSimpleType (((System.Xml.Schema.XmlSchemaSimpleType) ob.@Items[n3]), "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
93                                         }
94                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaAttribute)) {
95                                                 WriteObject_XmlSchemaAttribute (((System.Xml.Schema.XmlSchemaAttribute) ob.@Items[n3]), "attribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
96                                         }
97                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaAnnotation)) {
98                                                 WriteObject_XmlSchemaAnnotation (((System.Xml.Schema.XmlSchemaAnnotation) ob.@Items[n3]), "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
99                                         }
100                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroup)) {
101                                                 WriteObject_XmlSchemaAttributeGroup (((System.Xml.Schema.XmlSchemaAttributeGroup) ob.@Items[n3]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
102                                         }
103                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaGroup)) {
104                                                 WriteObject_XmlSchemaGroup (((System.Xml.Schema.XmlSchemaGroup) ob.@Items[n3]), "group", "http://www.w3.org/2001/XMLSchema", false, false, true);
105                                         }
106                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaComplexType)) {
107                                                 WriteObject_XmlSchemaComplexType (((System.Xml.Schema.XmlSchemaComplexType) ob.@Items[n3]), "complexType", "http://www.w3.org/2001/XMLSchema", false, false, true);
108                                         }
109                                         else if (ob.@Items[n3].GetType() == typeof(System.Xml.Schema.XmlSchemaNotation)) {
110                                                 WriteObject_XmlSchemaNotation (((System.Xml.Schema.XmlSchemaNotation) ob.@Items[n3]), "notation", "http://www.w3.org/2001/XMLSchema", false, false, true);
111                                         }
112                                         else throw CreateUnknownTypeException (ob.@Items[n3]);
113                                 }
114                         }
115                         if (writeWrappingElem) WriteEndElement (ob);
116                 }
117 /*
118                 void WriteObject_XmlSchemaForm (System.Xml.Schema.XmlSchemaForm ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
119                 {
120                         System.Type type = ob.GetType ();
121                         if (type == typeof(System.Xml.Schema.XmlSchemaForm))
122                                 ;
123                         else {
124                                 throw CreateUnknownTypeException (ob);
125                         }
126
127                         if (writeWrappingElem) {
128                                 WriteStartElement (element, namesp, ob);
129                         }
130
131                         if (needType) WriteXsiType("XmlSchemaForm", "");
132
133                         Writer.WriteString (GetEnumValue_XmlSchemaForm (ob));
134                         if (writeWrappingElem) WriteEndElement (ob);
135                 }
136 */
137                 string GetEnumValue_XmlSchemaForm (System.Xml.Schema.XmlSchemaForm val)
138                 {
139                         switch (val)
140                         {
141                                 case System.Xml.Schema.XmlSchemaForm.Qualified: return "qualified";
142                                 case System.Xml.Schema.XmlSchemaForm.Unqualified: return "unqualified";
143                                 default: return ((long)val).ToString(CultureInfo.InvariantCulture);
144                         }
145                 }
146 /*
147                 void WriteObject_XmlSchemaDerivationMethod (System.Xml.Schema.XmlSchemaDerivationMethod ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
148                 {
149                         System.Type type = ob.GetType ();
150                         if (type == typeof(System.Xml.Schema.XmlSchemaDerivationMethod))
151                                 ;
152                         else {
153                                 throw CreateUnknownTypeException (ob);
154                         }
155
156                         if (writeWrappingElem) {
157                                 WriteStartElement (element, namesp, ob);
158                         }
159
160                         if (needType) WriteXsiType("XmlSchemaDerivationMethod", "");
161
162                         Writer.WriteString (GetEnumValue_XmlSchemaDerivationMethod (ob));
163                         if (writeWrappingElem) WriteEndElement (ob);
164                 }
165 */
166                 string GetEnumValue_XmlSchemaDerivationMethod (System.Xml.Schema.XmlSchemaDerivationMethod val)
167                 {
168                         switch (val)
169                         {
170                                 case System.Xml.Schema.XmlSchemaDerivationMethod.Empty: return "";
171                                 case System.Xml.Schema.XmlSchemaDerivationMethod.Substitution: return "substitution";
172                                 case System.Xml.Schema.XmlSchemaDerivationMethod.Extension: return "extension";
173                                 case System.Xml.Schema.XmlSchemaDerivationMethod.Restriction: return "restriction";
174                                 case System.Xml.Schema.XmlSchemaDerivationMethod.List: return "list";
175                                 case System.Xml.Schema.XmlSchemaDerivationMethod.Union: return "union";
176                                 case System.Xml.Schema.XmlSchemaDerivationMethod.All: return "#all";
177                                 default:
178                                         System.Text.StringBuilder sb = new System.Text.StringBuilder ();
179                                         string[] enumNames = val.ToString().Split (',');
180                                         foreach (string name in enumNames)
181                                         {
182                                                 switch (name.Trim())
183                                                 {
184                                                         case "Empty": sb.Append ("").Append (' '); break; 
185                                                         case "Substitution": sb.Append ("substitution").Append (' '); break; 
186                                                         case "Extension": sb.Append ("extension").Append (' '); break; 
187                                                         case "Restriction": sb.Append ("restriction").Append (' '); break; 
188                                                         case "List": sb.Append ("list").Append (' '); break; 
189                                                         case "Union": sb.Append ("union").Append (' '); break; 
190                                                         case "All": sb.Append ("#all").Append (' '); break; 
191                                                         default: sb.Append (name.Trim()).Append (' '); break; 
192                                                 }
193                                         }
194                                         return sb.ToString ().Trim();
195                         }
196                 }
197
198                 void WriteObject_XmlSchemaInclude (System.Xml.Schema.XmlSchemaInclude ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
199                 {
200                         if (ob == null)
201                         {
202                                 if (isNullable)
203                                         WriteNullTagLiteral(element, namesp);
204                                 return;
205                         }
206
207                         System.Type type = ob.GetType ();
208                         if (type == typeof(System.Xml.Schema.XmlSchemaInclude))
209                                 ;
210                         else {
211                                 throw CreateUnknownTypeException (ob);
212                         }
213
214                         if (writeWrappingElem) {
215                                 WriteStartElement (element, namesp, ob);
216                         }
217
218                         if (needType) WriteXsiType("XmlSchemaInclude", "http://www.w3.org/2001/XMLSchema");
219
220                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
221
222                         ICollection o4 = ob.@UnhandledAttributes;
223                         if (o4 != null) {
224                                 foreach (XmlAttribute o5 in o4)
225                                         if (o5.NamespaceURI != xmlNamespace)
226                                                 WriteXmlAttribute (o5, ob);
227                         }
228
229                         WriteAttribute ("schemaLocation", "", ob.@SchemaLocation);
230                         WriteAttribute ("id", "", ob.@Id);
231
232                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
233                         if (writeWrappingElem) WriteEndElement (ob);
234                 }
235
236                 void WriteObject_XmlSchemaImport (System.Xml.Schema.XmlSchemaImport ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
237                 {
238                         if (ob == null)
239                         {
240                                 if (isNullable)
241                                         WriteNullTagLiteral(element, namesp);
242                                 return;
243                         }
244
245                         System.Type type = ob.GetType ();
246                         if (type == typeof(System.Xml.Schema.XmlSchemaImport))
247                                 ;
248                         else {
249                                 throw CreateUnknownTypeException (ob);
250                         }
251
252                         if (writeWrappingElem) {
253                                 WriteStartElement (element, namesp, ob);
254                         }
255
256                         if (needType) WriteXsiType("XmlSchemaImport", "http://www.w3.org/2001/XMLSchema");
257
258                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
259
260                         ICollection o6 = ob.@UnhandledAttributes;
261                         if (o6 != null) {
262                                 foreach (XmlAttribute o7 in o6)
263                                         if (o7.NamespaceURI != xmlNamespace)
264                                                 WriteXmlAttribute (o7, ob);
265                         }
266
267                         WriteAttribute ("schemaLocation", "", ob.@SchemaLocation);
268                         WriteAttribute ("id", "", ob.@Id);
269                         WriteAttribute ("namespace", "", ob.@Namespace);
270
271                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
272                         if (writeWrappingElem) WriteEndElement (ob);
273                 }
274
275                 void WriteObject_XmlSchemaRedefine (System.Xml.Schema.XmlSchemaRedefine ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
276                 {
277                         if (ob == null)
278                         {
279                                 if (isNullable)
280                                         WriteNullTagLiteral(element, namesp);
281                                 return;
282                         }
283
284                         System.Type type = ob.GetType ();
285                         if (type == typeof(System.Xml.Schema.XmlSchemaRedefine))
286                                 ;
287                         else {
288                                 throw CreateUnknownTypeException (ob);
289                         }
290
291                         if (writeWrappingElem) {
292                                 WriteStartElement (element, namesp, ob);
293                         }
294
295                         if (needType) WriteXsiType("XmlSchemaRedefine", "http://www.w3.org/2001/XMLSchema");
296
297                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
298
299                         ICollection o8 = ob.@UnhandledAttributes;
300                         if (o8 != null) {
301                                 foreach (XmlAttribute o9 in o8)
302                                         if (o9.NamespaceURI != xmlNamespace)
303                                                 WriteXmlAttribute (o9, ob);
304                         }
305
306                         WriteAttribute ("schemaLocation", "", ob.@SchemaLocation);
307                         WriteAttribute ("id", "", ob.@Id);
308
309                         if (ob.@Items != null) {
310                                 for (int n10 = 0; n10 < ob.@Items.Count; n10++) {
311                                         if (ob.@Items[n10] == null) { }
312                                         else if (ob.@Items[n10].GetType() == typeof(System.Xml.Schema.XmlSchemaGroup)) {
313                                                 WriteObject_XmlSchemaGroup (((System.Xml.Schema.XmlSchemaGroup) ob.@Items[n10]), "group", "http://www.w3.org/2001/XMLSchema", false, false, true);
314                                         }
315                                         else if (ob.@Items[n10].GetType() == typeof(System.Xml.Schema.XmlSchemaComplexType)) {
316                                                 WriteObject_XmlSchemaComplexType (((System.Xml.Schema.XmlSchemaComplexType) ob.@Items[n10]), "complexType", "http://www.w3.org/2001/XMLSchema", false, false, true);
317                                         }
318                                         else if (ob.@Items[n10].GetType() == typeof(System.Xml.Schema.XmlSchemaSimpleType)) {
319                                                 WriteObject_XmlSchemaSimpleType (((System.Xml.Schema.XmlSchemaSimpleType) ob.@Items[n10]), "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
320                                         }
321                                         else if (ob.@Items[n10].GetType() == typeof(System.Xml.Schema.XmlSchemaAnnotation)) {
322                                                 WriteObject_XmlSchemaAnnotation (((System.Xml.Schema.XmlSchemaAnnotation) ob.@Items[n10]), "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
323                                         }
324                                         else if (ob.@Items[n10].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroup)) {
325                                                 WriteObject_XmlSchemaAttributeGroup (((System.Xml.Schema.XmlSchemaAttributeGroup) ob.@Items[n10]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
326                                         }
327                                         else throw CreateUnknownTypeException (ob.@Items[n10]);
328                                 }
329                         }
330                         if (writeWrappingElem) WriteEndElement (ob);
331                 }
332
333                 void WriteObject_XmlSchemaElement (System.Xml.Schema.XmlSchemaElement ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
334                 {
335                         if (ob == null)
336                         {
337                                 if (isNullable)
338                                         WriteNullTagLiteral(element, namesp);
339                                 return;
340                         }
341
342                         System.Type type = ob.GetType ();
343                         if (type == typeof(System.Xml.Schema.XmlSchemaElement))
344                                 ;
345                         else {
346                                 throw CreateUnknownTypeException (ob);
347                         }
348
349                         if (writeWrappingElem) {
350                                 WriteStartElement (element, namesp, ob);
351                         }
352
353                         if (needType) WriteXsiType("XmlSchemaElement", "http://www.w3.org/2001/XMLSchema");
354
355                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
356
357                         ICollection o11 = ob.@UnhandledAttributes;
358                         if (o11 != null) {
359                                 foreach (XmlAttribute o12 in o11)
360                                         if (o12.NamespaceURI != xmlNamespace)
361                                                 WriteXmlAttribute (o12, ob);
362                         }
363
364                         WriteAttribute ("id", "", ob.@Id);
365                         WriteAttribute ("minOccurs", "", ob.@MinOccursString);
366                         WriteAttribute ("maxOccurs", "", ob.@MaxOccursString);
367                         if (ob.@IsAbstract != false) {
368                                 WriteAttribute ("abstract", "", (ob.@IsAbstract?"true":"false"));
369                         }
370                         if (ob.@Block != ((System.Xml.Schema.XmlSchemaDerivationMethod) System.Xml.Schema.XmlSchemaDerivationMethod.None)) {
371                                 WriteAttribute ("block", "", GetEnumValue_XmlSchemaDerivationMethod (ob.@Block));
372                         }
373                         if (ob.@DefaultValue != null) {
374                                 WriteAttribute ("default", "", ob.@DefaultValue);
375                         }
376                         if (ob.@Final != ((System.Xml.Schema.XmlSchemaDerivationMethod) System.Xml.Schema.XmlSchemaDerivationMethod.None)) {
377                                 WriteAttribute ("final", "", GetEnumValue_XmlSchemaDerivationMethod (ob.@Final));
378                         }
379                         if (ob.@FixedValue != null) {
380                                 WriteAttribute ("fixed", "", ob.@FixedValue);
381                         }
382                         if (ob.@Form != ((System.Xml.Schema.XmlSchemaForm) System.Xml.Schema.XmlSchemaForm.None)) {
383                                 WriteAttribute ("form", "", GetEnumValue_XmlSchemaForm (ob.@Form));
384                         }
385                         if (ob.@Name != null) {
386                                 WriteAttribute ("name", "", ob.@Name);
387                         }
388                         if (ob.@IsNillable != false) {
389                                 WriteAttribute ("nillable", "", (ob.@IsNillable?"true":"false"));
390                         }
391                         WriteAttribute ("ref", "", FromXmlQualifiedName (ob.@RefName));
392                         WriteAttribute ("substitutionGroup", "", FromXmlQualifiedName (ob.@SubstitutionGroup));
393                         WriteAttribute ("type", "", FromXmlQualifiedName (ob.@SchemaTypeName));
394
395                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
396                         if (ob.@SchemaType is System.Xml.Schema.XmlSchemaSimpleType) {
397                                 WriteObject_XmlSchemaSimpleType (((System.Xml.Schema.XmlSchemaSimpleType) ob.@SchemaType), "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
398                         }
399                         else if (ob.@SchemaType is System.Xml.Schema.XmlSchemaComplexType) {
400                                 WriteObject_XmlSchemaComplexType (((System.Xml.Schema.XmlSchemaComplexType) ob.@SchemaType), "complexType", "http://www.w3.org/2001/XMLSchema", false, false, true);
401                         }
402                         if (ob.@Constraints != null) {
403                                 for (int n13 = 0; n13 < ob.@Constraints.Count; n13++) {
404                                         if (ob.@Constraints[n13] == null) { }
405                                         else if (ob.@Constraints[n13].GetType() == typeof(System.Xml.Schema.XmlSchemaKeyref)) {
406                                                 WriteObject_XmlSchemaKeyref (((System.Xml.Schema.XmlSchemaKeyref) ob.@Constraints[n13]), "keyref", "http://www.w3.org/2001/XMLSchema", false, false, true);
407                                         }
408                                         else if (ob.@Constraints[n13].GetType() == typeof(System.Xml.Schema.XmlSchemaKey)) {
409                                                 WriteObject_XmlSchemaKey (((System.Xml.Schema.XmlSchemaKey) ob.@Constraints[n13]), "key", "http://www.w3.org/2001/XMLSchema", false, false, true);
410                                         }
411                                         else if (ob.@Constraints[n13].GetType() == typeof(System.Xml.Schema.XmlSchemaUnique)) {
412                                                 WriteObject_XmlSchemaUnique (((System.Xml.Schema.XmlSchemaUnique) ob.@Constraints[n13]), "unique", "http://www.w3.org/2001/XMLSchema", false, false, true);
413                                         }
414                                         else throw CreateUnknownTypeException (ob.@Constraints[n13]);
415                                 }
416                         }
417                         if (writeWrappingElem) WriteEndElement (ob);
418                 }
419
420                 void WriteObject_XmlSchemaSimpleType (System.Xml.Schema.XmlSchemaSimpleType ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
421                 {
422                         if (ob == null)
423                         {
424                                 if (isNullable)
425                                         WriteNullTagLiteral(element, namesp);
426                                 return;
427                         }
428
429                         System.Type type = ob.GetType ();
430                         if (type == typeof(System.Xml.Schema.XmlSchemaSimpleType))
431                                 ;
432                         else {
433                                 throw CreateUnknownTypeException (ob);
434                         }
435
436                         if (writeWrappingElem) {
437                                 WriteStartElement (element, namesp, ob);
438                         }
439
440                         if (needType) WriteXsiType("XmlSchemaSimpleType", "http://www.w3.org/2001/XMLSchema");
441
442                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
443
444                         ICollection o14 = ob.@UnhandledAttributes;
445                         if (o14 != null) {
446                                 foreach (XmlAttribute o15 in o14)
447                                         if (o15.NamespaceURI != xmlNamespace)
448                                                 WriteXmlAttribute (o15, ob);
449                         }
450
451                         WriteAttribute ("id", "", ob.@Id);
452                         WriteAttribute ("name", "", ob.@Name);
453                         if (ob.@Final != ((System.Xml.Schema.XmlSchemaDerivationMethod) System.Xml.Schema.XmlSchemaDerivationMethod.None)) {
454                                 WriteAttribute ("final", "", GetEnumValue_XmlSchemaDerivationMethod (ob.@Final));
455                         }
456
457                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
458                         if (ob.@Content is System.Xml.Schema.XmlSchemaSimpleTypeUnion) {
459                                 WriteObject_XmlSchemaSimpleTypeUnion (((System.Xml.Schema.XmlSchemaSimpleTypeUnion) ob.@Content), "union", "http://www.w3.org/2001/XMLSchema", false, false, true);
460                         }
461                         else if (ob.@Content is System.Xml.Schema.XmlSchemaSimpleTypeList) {
462                                 WriteObject_XmlSchemaSimpleTypeList (((System.Xml.Schema.XmlSchemaSimpleTypeList) ob.@Content), "list", "http://www.w3.org/2001/XMLSchema", false, false, true);
463                         }
464                         else if (ob.@Content is System.Xml.Schema.XmlSchemaSimpleTypeRestriction) {
465                                 WriteObject_XmlSchemaSimpleTypeRestriction (((System.Xml.Schema.XmlSchemaSimpleTypeRestriction) ob.@Content), "restriction", "http://www.w3.org/2001/XMLSchema", false, false, true);
466                         }
467                         if (writeWrappingElem) WriteEndElement (ob);
468                 }
469
470                 void WriteObject_XmlSchemaAttribute (System.Xml.Schema.XmlSchemaAttribute ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
471                 {
472                         if (ob == null)
473                         {
474                                 if (isNullable)
475                                         WriteNullTagLiteral(element, namesp);
476                                 return;
477                         }
478
479                         System.Type type = ob.GetType ();
480                         if (type == typeof(System.Xml.Schema.XmlSchemaAttribute))
481                                 ;
482                         else {
483                                 throw CreateUnknownTypeException (ob);
484                         }
485
486                         if (writeWrappingElem) {
487                                 WriteStartElement (element, namesp, ob);
488                         }
489
490                         if (needType) WriteXsiType("XmlSchemaAttribute", "http://www.w3.org/2001/XMLSchema");
491
492                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
493
494                         ICollection o16 = ob.@UnhandledAttributes;
495                         if (o16 != null) {
496                                 foreach (XmlAttribute o17 in o16)
497                                         if (o17.NamespaceURI != xmlNamespace)
498                                                 WriteXmlAttribute (o17, ob);
499                         }
500
501                         WriteAttribute ("id", "", ob.@Id);
502                         if (ob.@DefaultValue != null) {
503                                 WriteAttribute ("default", "", ob.@DefaultValue);
504                         }
505                         if (ob.@FixedValue != null) {
506                                 WriteAttribute ("fixed", "", ob.@FixedValue);
507                         }
508                         if (ob.@Form != ((System.Xml.Schema.XmlSchemaForm) System.Xml.Schema.XmlSchemaForm.None)) {
509                                 WriteAttribute ("form", "", GetEnumValue_XmlSchemaForm (ob.@Form));
510                         }
511                         WriteAttribute ("name", "", ob.@Name);
512                         WriteAttribute ("ref", "", FromXmlQualifiedName (ob.@RefName));
513                         WriteAttribute ("type", "", FromXmlQualifiedName (ob.@SchemaTypeName));
514                         if (ob.@Use != ((System.Xml.Schema.XmlSchemaUse) System.Xml.Schema.XmlSchemaUse.None)) {
515                                 WriteAttribute ("use", "", GetEnumValue_XmlSchemaUse (ob.@Use));
516                         }
517
518                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
519                         WriteObject_XmlSchemaSimpleType (ob.@SchemaType, "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
520                         if (writeWrappingElem) WriteEndElement (ob);
521                 }
522
523                 void WriteObject_XmlSchemaAnnotation (System.Xml.Schema.XmlSchemaAnnotation ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
524                 {
525                         if (ob == null)
526                         {
527                                 if (isNullable)
528                                         WriteNullTagLiteral(element, namesp);
529                                 return;
530                         }
531
532                         System.Type type = ob.GetType ();
533                         if (type == typeof(System.Xml.Schema.XmlSchemaAnnotation))
534                                 ;
535                         else {
536                                 throw CreateUnknownTypeException (ob);
537                         }
538
539                         if (writeWrappingElem) {
540                                 WriteStartElement (element, namesp, ob);
541                         }
542
543                         if (needType) WriteXsiType("XmlSchemaAnnotation", "http://www.w3.org/2001/XMLSchema");
544
545                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
546
547                         ICollection o18 = ob.@UnhandledAttributes;
548                         if (o18 != null) {
549                                 foreach (XmlAttribute o19 in o18)
550                                         if (o19.NamespaceURI != xmlNamespace)
551                                                 WriteXmlAttribute (o19, ob);
552                         }
553
554                         WriteAttribute ("id", "", ob.@Id);
555
556                         if (ob.@Items != null) {
557                                 for (int n20 = 0; n20 < ob.@Items.Count; n20++) {
558                                         if (ob.@Items[n20] == null) { }
559                                         else if (ob.@Items[n20].GetType() == typeof(System.Xml.Schema.XmlSchemaAppInfo)) {
560                                                 WriteObject_XmlSchemaAppInfo (((System.Xml.Schema.XmlSchemaAppInfo) ob.@Items[n20]), "appinfo", "http://www.w3.org/2001/XMLSchema", false, false, true);
561                                         }
562                                         else if (ob.@Items[n20].GetType() == typeof(System.Xml.Schema.XmlSchemaDocumentation)) {
563                                                 WriteObject_XmlSchemaDocumentation (((System.Xml.Schema.XmlSchemaDocumentation) ob.@Items[n20]), "documentation", "http://www.w3.org/2001/XMLSchema", false, false, true);
564                                         }
565                                         else throw CreateUnknownTypeException (ob.@Items[n20]);
566                                 }
567                         }
568                         if (writeWrappingElem) WriteEndElement (ob);
569                 }
570
571                 void WriteObject_XmlSchemaAttributeGroup (System.Xml.Schema.XmlSchemaAttributeGroup ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
572                 {
573                         if (ob == null)
574                         {
575                                 if (isNullable)
576                                         WriteNullTagLiteral(element, namesp);
577                                 return;
578                         }
579
580                         System.Type type = ob.GetType ();
581                         if (type == typeof(System.Xml.Schema.XmlSchemaAttributeGroup))
582                                 ;
583                         else {
584                                 throw CreateUnknownTypeException (ob);
585                         }
586
587                         if (writeWrappingElem) {
588                                 WriteStartElement (element, namesp, ob);
589                         }
590
591                         if (needType) WriteXsiType("XmlSchemaAttributeGroup", "http://www.w3.org/2001/XMLSchema");
592
593                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
594
595                         ICollection o21 = ob.@UnhandledAttributes;
596                         if (o21 != null) {
597                                 foreach (XmlAttribute o22 in o21)
598                                         if (o22.NamespaceURI != xmlNamespace)
599                                                 WriteXmlAttribute (o22, ob);
600                         }
601
602                         WriteAttribute ("id", "", ob.@Id);
603                         WriteAttribute ("name", "", ob.@Name);
604
605                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
606                         if (ob.@Attributes != null) {
607                                 for (int n23 = 0; n23 < ob.@Attributes.Count; n23++) {
608                                         if (ob.@Attributes[n23] == null) { }
609                                         else if (ob.@Attributes[n23].GetType() == typeof(System.Xml.Schema.XmlSchemaAttribute)) {
610                                                 WriteObject_XmlSchemaAttribute (((System.Xml.Schema.XmlSchemaAttribute) ob.@Attributes[n23]), "attribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
611                                         }
612                                         else if (ob.@Attributes[n23].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) {
613                                                 WriteObject_XmlSchemaAttributeGroupRef (((System.Xml.Schema.XmlSchemaAttributeGroupRef) ob.@Attributes[n23]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
614                                         }
615                                         else throw CreateUnknownTypeException (ob.@Attributes[n23]);
616                                 }
617                         }
618                         WriteObject_XmlSchemaAnyAttribute (ob.@AnyAttribute, "anyAttribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
619                         if (writeWrappingElem) WriteEndElement (ob);
620                 }
621
622                 void WriteObject_XmlSchemaGroup (System.Xml.Schema.XmlSchemaGroup ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
623                 {
624                         if (ob == null)
625                         {
626                                 if (isNullable)
627                                         WriteNullTagLiteral(element, namesp);
628                                 return;
629                         }
630
631                         System.Type type = ob.GetType ();
632                         if (type == typeof(System.Xml.Schema.XmlSchemaGroup))
633                                 ;
634                         else {
635                                 throw CreateUnknownTypeException (ob);
636                         }
637
638                         if (writeWrappingElem) {
639                                 WriteStartElement (element, namesp, ob);
640                         }
641
642                         if (needType) WriteXsiType("XmlSchemaGroup", "http://www.w3.org/2001/XMLSchema");
643
644                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
645
646                         ICollection o24 = ob.@UnhandledAttributes;
647                         if (o24 != null) {
648                                 foreach (XmlAttribute o25 in o24)
649                                         if (o25.NamespaceURI != xmlNamespace)
650                                                 WriteXmlAttribute (o25, ob);
651                         }
652
653                         WriteAttribute ("id", "", ob.@Id);
654                         WriteAttribute ("name", "", ob.@Name);
655
656                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
657                         if (ob.@Particle is System.Xml.Schema.XmlSchemaSequence) {
658                                 WriteObject_XmlSchemaSequence (((System.Xml.Schema.XmlSchemaSequence) ob.@Particle), "sequence", "http://www.w3.org/2001/XMLSchema", false, false, true);
659                         }
660                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaChoice) {
661                                 WriteObject_XmlSchemaChoice (((System.Xml.Schema.XmlSchemaChoice) ob.@Particle), "choice", "http://www.w3.org/2001/XMLSchema", false, false, true);
662                         }
663                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaAll) {
664                                 WriteObject_XmlSchemaAll (((System.Xml.Schema.XmlSchemaAll) ob.@Particle), "all", "http://www.w3.org/2001/XMLSchema", false, false, true);
665                         }
666                         if (writeWrappingElem) WriteEndElement (ob);
667                 }
668
669                 void WriteObject_XmlSchemaComplexType (System.Xml.Schema.XmlSchemaComplexType ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
670                 {
671                         if (ob == null)
672                         {
673                                 if (isNullable)
674                                         WriteNullTagLiteral(element, namesp);
675                                 return;
676                         }
677
678                         System.Type type = ob.GetType ();
679                         if (type == typeof(System.Xml.Schema.XmlSchemaComplexType))
680                                 ;
681                         else {
682                                 throw CreateUnknownTypeException (ob);
683                         }
684
685                         if (writeWrappingElem) {
686                                 WriteStartElement (element, namesp, ob);
687                         }
688
689                         if (needType) WriteXsiType("XmlSchemaComplexType", "http://www.w3.org/2001/XMLSchema");
690
691                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
692
693                         ICollection o26 = ob.@UnhandledAttributes;
694                         if (o26 != null) {
695                                 foreach (XmlAttribute o27 in o26)
696                                         if (o27.NamespaceURI != xmlNamespace)
697                                                 WriteXmlAttribute (o27, ob);
698                         }
699
700                         WriteAttribute ("id", "", ob.@Id);
701                         WriteAttribute ("name", "", ob.@Name);
702                         if (ob.@Final != ((System.Xml.Schema.XmlSchemaDerivationMethod) System.Xml.Schema.XmlSchemaDerivationMethod.None)) {
703                                 WriteAttribute ("final", "", GetEnumValue_XmlSchemaDerivationMethod (ob.@Final));
704                         }
705                         if (ob.@IsAbstract != false) {
706                                 WriteAttribute ("abstract", "", (ob.@IsAbstract?"true":"false"));
707                         }
708                         if (ob.@Block != ((System.Xml.Schema.XmlSchemaDerivationMethod) System.Xml.Schema.XmlSchemaDerivationMethod.None)) {
709                                 WriteAttribute ("block", "", GetEnumValue_XmlSchemaDerivationMethod (ob.@Block));
710                         }
711                         if (ob.@IsMixed != false) {
712                                 WriteAttribute ("mixed", "", (ob.@IsMixed?"true":"false"));
713                         }
714
715                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
716                         if (ob.@ContentModel is System.Xml.Schema.XmlSchemaComplexContent) {
717                                 WriteObject_XmlSchemaComplexContent (((System.Xml.Schema.XmlSchemaComplexContent) ob.@ContentModel), "complexContent", "http://www.w3.org/2001/XMLSchema", false, false, true);
718                         }
719                         else if (ob.@ContentModel is System.Xml.Schema.XmlSchemaSimpleContent) {
720                                 WriteObject_XmlSchemaSimpleContent (((System.Xml.Schema.XmlSchemaSimpleContent) ob.@ContentModel), "simpleContent", "http://www.w3.org/2001/XMLSchema", false, false, true);
721                         }
722                         if (ob.@Particle is System.Xml.Schema.XmlSchemaAll) {
723                                 WriteObject_XmlSchemaAll (((System.Xml.Schema.XmlSchemaAll) ob.@Particle), "all", "http://www.w3.org/2001/XMLSchema", false, false, true);
724                         }
725                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaGroupRef) {
726                                 WriteObject_XmlSchemaGroupRef (((System.Xml.Schema.XmlSchemaGroupRef) ob.@Particle), "group", "http://www.w3.org/2001/XMLSchema", false, false, true);
727                         }
728                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaSequence) {
729                                 WriteObject_XmlSchemaSequence (((System.Xml.Schema.XmlSchemaSequence) ob.@Particle), "sequence", "http://www.w3.org/2001/XMLSchema", false, false, true);
730                         }
731                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaChoice) {
732                                 WriteObject_XmlSchemaChoice (((System.Xml.Schema.XmlSchemaChoice) ob.@Particle), "choice", "http://www.w3.org/2001/XMLSchema", false, false, true);
733                         }
734                         if (ob.@Attributes != null) {
735                                 for (int n28 = 0; n28 < ob.@Attributes.Count; n28++) {
736                                         if (ob.@Attributes[n28] == null) { }
737                                         else if (ob.@Attributes[n28].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) {
738                                                 WriteObject_XmlSchemaAttributeGroupRef (((System.Xml.Schema.XmlSchemaAttributeGroupRef) ob.@Attributes[n28]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
739                                         }
740                                         else if (ob.@Attributes[n28].GetType() == typeof(System.Xml.Schema.XmlSchemaAttribute)) {
741                                                 WriteObject_XmlSchemaAttribute (((System.Xml.Schema.XmlSchemaAttribute) ob.@Attributes[n28]), "attribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
742                                         }
743                                         else throw CreateUnknownTypeException (ob.@Attributes[n28]);
744                                 }
745                         }
746                         WriteObject_XmlSchemaAnyAttribute (ob.@AnyAttribute, "anyAttribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
747                         if (writeWrappingElem) WriteEndElement (ob);
748                 }
749
750                 void WriteObject_XmlSchemaNotation (System.Xml.Schema.XmlSchemaNotation ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
751                 {
752                         if (ob == null)
753                         {
754                                 if (isNullable)
755                                         WriteNullTagLiteral(element, namesp);
756                                 return;
757                         }
758
759                         System.Type type = ob.GetType ();
760                         if (type == typeof(System.Xml.Schema.XmlSchemaNotation))
761                                 ;
762                         else {
763                                 throw CreateUnknownTypeException (ob);
764                         }
765
766                         if (writeWrappingElem) {
767                                 WriteStartElement (element, namesp, ob);
768                         }
769
770                         if (needType) WriteXsiType("XmlSchemaNotation", "http://www.w3.org/2001/XMLSchema");
771
772                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
773
774                         ICollection o29 = ob.@UnhandledAttributes;
775                         if (o29 != null) {
776                                 foreach (XmlAttribute o30 in o29)
777                                         if (o30.NamespaceURI != xmlNamespace)
778                                                 WriteXmlAttribute (o30, ob);
779                         }
780
781                         WriteAttribute ("id", "", ob.@Id);
782                         WriteAttribute ("name", "", ob.@Name);
783                         WriteAttribute ("public", "", ob.@Public);
784                         WriteAttribute ("system", "", ob.@System);
785
786                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
787                         if (writeWrappingElem) WriteEndElement (ob);
788                 }
789
790                 void WriteObject_XmlSchemaKeyref (System.Xml.Schema.XmlSchemaKeyref ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
791                 {
792                         if (ob == null)
793                         {
794                                 if (isNullable)
795                                         WriteNullTagLiteral(element, namesp);
796                                 return;
797                         }
798
799                         System.Type type = ob.GetType ();
800                         if (type == typeof(System.Xml.Schema.XmlSchemaKeyref))
801                                 ;
802                         else {
803                                 throw CreateUnknownTypeException (ob);
804                         }
805
806                         if (writeWrappingElem) {
807                                 WriteStartElement (element, namesp, ob);
808                         }
809
810                         if (needType) WriteXsiType("XmlSchemaKeyref", "http://www.w3.org/2001/XMLSchema");
811
812                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
813
814                         ICollection o31 = ob.@UnhandledAttributes;
815                         if (o31 != null) {
816                                 foreach (XmlAttribute o32 in o31)
817                                         if (o32.NamespaceURI != xmlNamespace)
818                                                 WriteXmlAttribute (o32, ob);
819                         }
820
821                         WriteAttribute ("id", "", ob.@Id);
822                         WriteAttribute ("name", "", ob.@Name);
823                         WriteAttribute ("refer", "", FromXmlQualifiedName (ob.@Refer));
824
825                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
826                         WriteObject_XmlSchemaXPath (ob.@Selector, "selector", "http://www.w3.org/2001/XMLSchema", false, false, true);
827                         if (ob.@Fields != null) {
828                                 for (int n33 = 0; n33 < ob.@Fields.Count; n33++) {
829                                         WriteObject_XmlSchemaXPath (((System.Xml.Schema.XmlSchemaXPath) ob.@Fields[n33]), "field", "http://www.w3.org/2001/XMLSchema", false, false, true);
830                                 }
831                         }
832                         if (writeWrappingElem) WriteEndElement (ob);
833                 }
834
835                 void WriteObject_XmlSchemaKey (System.Xml.Schema.XmlSchemaKey ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
836                 {
837                         if (ob == null)
838                         {
839                                 if (isNullable)
840                                         WriteNullTagLiteral(element, namesp);
841                                 return;
842                         }
843
844                         System.Type type = ob.GetType ();
845                         if (type == typeof(System.Xml.Schema.XmlSchemaKey))
846                                 ;
847                         else {
848                                 throw CreateUnknownTypeException (ob);
849                         }
850
851                         if (writeWrappingElem) {
852                                 WriteStartElement (element, namesp, ob);
853                         }
854
855                         if (needType) WriteXsiType("XmlSchemaKey", "http://www.w3.org/2001/XMLSchema");
856
857                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
858
859                         ICollection o34 = ob.@UnhandledAttributes;
860                         if (o34 != null) {
861                                 foreach (XmlAttribute o35 in o34)
862                                         if (o35.NamespaceURI != xmlNamespace)
863                                                 WriteXmlAttribute (o35, ob);
864                         }
865
866                         WriteAttribute ("id", "", ob.@Id);
867                         WriteAttribute ("name", "", ob.@Name);
868
869                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
870                         WriteObject_XmlSchemaXPath (ob.@Selector, "selector", "http://www.w3.org/2001/XMLSchema", false, false, true);
871                         if (ob.@Fields != null) {
872                                 for (int n36 = 0; n36 < ob.@Fields.Count; n36++) {
873                                         WriteObject_XmlSchemaXPath (((System.Xml.Schema.XmlSchemaXPath) ob.@Fields[n36]), "field", "http://www.w3.org/2001/XMLSchema", false, false, true);
874                                 }
875                         }
876                         if (writeWrappingElem) WriteEndElement (ob);
877                 }
878
879                 void WriteObject_XmlSchemaUnique (System.Xml.Schema.XmlSchemaUnique ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
880                 {
881                         if (ob == null)
882                         {
883                                 if (isNullable)
884                                         WriteNullTagLiteral(element, namesp);
885                                 return;
886                         }
887
888                         System.Type type = ob.GetType ();
889                         if (type == typeof(System.Xml.Schema.XmlSchemaUnique))
890                                 ;
891                         else {
892                                 throw CreateUnknownTypeException (ob);
893                         }
894
895                         if (writeWrappingElem) {
896                                 WriteStartElement (element, namesp, ob);
897                         }
898
899                         if (needType) WriteXsiType("XmlSchemaUnique", "http://www.w3.org/2001/XMLSchema");
900
901                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
902
903                         ICollection o37 = ob.@UnhandledAttributes;
904                         if (o37 != null) {
905                                 foreach (XmlAttribute o38 in o37)
906                                         if (o38.NamespaceURI != xmlNamespace)
907                                                 WriteXmlAttribute (o38, ob);
908                         }
909
910                         WriteAttribute ("id", "", ob.@Id);
911                         WriteAttribute ("name", "", ob.@Name);
912
913                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
914                         WriteObject_XmlSchemaXPath (ob.@Selector, "selector", "http://www.w3.org/2001/XMLSchema", false, false, true);
915                         if (ob.@Fields != null) {
916                                 for (int n39 = 0; n39 < ob.@Fields.Count; n39++) {
917                                         WriteObject_XmlSchemaXPath (((System.Xml.Schema.XmlSchemaXPath) ob.@Fields[n39]), "field", "http://www.w3.org/2001/XMLSchema", false, false, true);
918                                 }
919                         }
920                         if (writeWrappingElem) WriteEndElement (ob);
921                 }
922
923                 void WriteObject_XmlSchemaSimpleTypeUnion (System.Xml.Schema.XmlSchemaSimpleTypeUnion ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
924                 {
925                         if (ob == null)
926                         {
927                                 if (isNullable)
928                                         WriteNullTagLiteral(element, namesp);
929                                 return;
930                         }
931
932                         System.Type type = ob.GetType ();
933                         if (type == typeof(System.Xml.Schema.XmlSchemaSimpleTypeUnion))
934                                 ;
935                         else {
936                                 throw CreateUnknownTypeException (ob);
937                         }
938
939                         if (writeWrappingElem) {
940                                 WriteStartElement (element, namesp, ob);
941                         }
942
943                         if (needType) WriteXsiType("XmlSchemaSimpleTypeUnion", "http://www.w3.org/2001/XMLSchema");
944
945                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
946
947                         ICollection o40 = ob.@UnhandledAttributes;
948                         if (o40 != null) {
949                                 foreach (XmlAttribute o41 in o40)
950                                         if (o41.NamespaceURI != xmlNamespace)
951                                                 WriteXmlAttribute (o41, ob);
952                         }
953
954                         WriteAttribute ("id", "", ob.@Id);
955                         string s42 = null;
956                         if (ob.@MemberTypes != null) {
957                                 System.Text.StringBuilder s43 = new System.Text.StringBuilder();
958                                 for (int n44 = 0; n44 < ob.@MemberTypes.Length; n44++) {
959                                         s43.Append (FromXmlQualifiedName (ob.@MemberTypes[n44])).Append (" ");
960                                 }
961                                 s42 = s43.ToString ().Trim ();
962                         }
963                         WriteAttribute ("memberTypes", "", s42);
964
965                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
966                         if (ob.@BaseTypes != null) {
967                                 for (int n45 = 0; n45 < ob.@BaseTypes.Count; n45++) {
968                                         WriteObject_XmlSchemaSimpleType (((System.Xml.Schema.XmlSchemaSimpleType) ob.@BaseTypes[n45]), "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
969                                 }
970                         }
971                         if (writeWrappingElem) WriteEndElement (ob);
972                 }
973
974                 void WriteObject_XmlSchemaSimpleTypeList (System.Xml.Schema.XmlSchemaSimpleTypeList ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
975                 {
976                         if (ob == null)
977                         {
978                                 if (isNullable)
979                                         WriteNullTagLiteral(element, namesp);
980                                 return;
981                         }
982
983                         System.Type type = ob.GetType ();
984                         if (type == typeof(System.Xml.Schema.XmlSchemaSimpleTypeList))
985                                 ;
986                         else {
987                                 throw CreateUnknownTypeException (ob);
988                         }
989
990                         if (writeWrappingElem) {
991                                 WriteStartElement (element, namesp, ob);
992                         }
993
994                         if (needType) WriteXsiType("XmlSchemaSimpleTypeList", "http://www.w3.org/2001/XMLSchema");
995
996                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
997
998                         ICollection o46 = ob.@UnhandledAttributes;
999                         if (o46 != null) {
1000                                 foreach (XmlAttribute o47 in o46)
1001                                         if (o47.NamespaceURI != xmlNamespace)
1002                                                 WriteXmlAttribute (o47, ob);
1003                         }
1004
1005                         WriteAttribute ("id", "", ob.@Id);
1006                         WriteAttribute ("itemType", "", FromXmlQualifiedName (ob.@ItemTypeName));
1007
1008                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1009                         WriteObject_XmlSchemaSimpleType (ob.@ItemType, "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
1010                         if (writeWrappingElem) WriteEndElement (ob);
1011                 }
1012
1013                 void WriteObject_XmlSchemaSimpleTypeRestriction (System.Xml.Schema.XmlSchemaSimpleTypeRestriction ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1014                 {
1015                         if (ob == null)
1016                         {
1017                                 if (isNullable)
1018                                         WriteNullTagLiteral(element, namesp);
1019                                 return;
1020                         }
1021
1022                         System.Type type = ob.GetType ();
1023                         if (type == typeof(System.Xml.Schema.XmlSchemaSimpleTypeRestriction))
1024                                 ;
1025                         else {
1026                                 throw CreateUnknownTypeException (ob);
1027                         }
1028
1029                         if (writeWrappingElem) {
1030                                 WriteStartElement (element, namesp, ob);
1031                         }
1032
1033                         if (needType) WriteXsiType("XmlSchemaSimpleTypeRestriction", "http://www.w3.org/2001/XMLSchema");
1034
1035                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1036
1037                         ICollection o48 = ob.@UnhandledAttributes;
1038                         if (o48 != null) {
1039                                 foreach (XmlAttribute o49 in o48)
1040                                         if (o49.NamespaceURI != xmlNamespace)
1041                                                 WriteXmlAttribute (o49, ob);
1042                         }
1043
1044                         WriteAttribute ("id", "", ob.@Id);
1045                         WriteAttribute ("base", "", FromXmlQualifiedName (ob.@BaseTypeName));
1046
1047                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1048                         WriteObject_XmlSchemaSimpleType (ob.@BaseType, "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
1049                         if (ob.@Facets != null) {
1050                                 for (int n50 = 0; n50 < ob.@Facets.Count; n50++) {
1051                                         if (ob.@Facets[n50] == null) { }
1052                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaMaxLengthFacet)) {
1053                                                 WriteObject_XmlSchemaMaxLengthFacet (((System.Xml.Schema.XmlSchemaMaxLengthFacet) ob.@Facets[n50]), "maxLength", "http://www.w3.org/2001/XMLSchema", false, false, true);
1054                                         }
1055                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaMinLengthFacet)) {
1056                                                 WriteObject_XmlSchemaMinLengthFacet (((System.Xml.Schema.XmlSchemaMinLengthFacet) ob.@Facets[n50]), "minLength", "http://www.w3.org/2001/XMLSchema", false, false, true);
1057                                         }
1058                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaLengthFacet)) {
1059                                                 WriteObject_XmlSchemaLengthFacet (((System.Xml.Schema.XmlSchemaLengthFacet) ob.@Facets[n50]), "length", "http://www.w3.org/2001/XMLSchema", false, false, true);
1060                                         }
1061                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaFractionDigitsFacet)) {
1062                                                 WriteObject_XmlSchemaFractionDigitsFacet (((System.Xml.Schema.XmlSchemaFractionDigitsFacet) ob.@Facets[n50]), "fractionDigits", "http://www.w3.org/2001/XMLSchema", false, false, true);
1063                                         }
1064                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaMaxInclusiveFacet)) {
1065                                                 WriteObject_XmlSchemaMaxInclusiveFacet (((System.Xml.Schema.XmlSchemaMaxInclusiveFacet) ob.@Facets[n50]), "maxInclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
1066                                         }
1067                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaMaxExclusiveFacet)) {
1068                                                 WriteObject_XmlSchemaMaxExclusiveFacet (((System.Xml.Schema.XmlSchemaMaxExclusiveFacet) ob.@Facets[n50]), "maxExclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
1069                                         }
1070                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaMinExclusiveFacet)) {
1071                                                 WriteObject_XmlSchemaMinExclusiveFacet (((System.Xml.Schema.XmlSchemaMinExclusiveFacet) ob.@Facets[n50]), "minExclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
1072                                         }
1073                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaEnumerationFacet)) {
1074                                                 WriteObject_XmlSchemaEnumerationFacet (((System.Xml.Schema.XmlSchemaEnumerationFacet) ob.@Facets[n50]), "enumeration", "http://www.w3.org/2001/XMLSchema", false, false, true);
1075                                         }
1076                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaTotalDigitsFacet)) {
1077                                                 WriteObject_XmlSchemaTotalDigitsFacet (((System.Xml.Schema.XmlSchemaTotalDigitsFacet) ob.@Facets[n50]), "totalDigits", "http://www.w3.org/2001/XMLSchema", false, false, true);
1078                                         }
1079                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaMinInclusiveFacet)) {
1080                                                 WriteObject_XmlSchemaMinInclusiveFacet (((System.Xml.Schema.XmlSchemaMinInclusiveFacet) ob.@Facets[n50]), "minInclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
1081                                         }
1082                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaWhiteSpaceFacet)) {
1083                                                 WriteObject_XmlSchemaWhiteSpaceFacet (((System.Xml.Schema.XmlSchemaWhiteSpaceFacet) ob.@Facets[n50]), "whiteSpace", "http://www.w3.org/2001/XMLSchema", false, false, true);
1084                                         }
1085                                         else if (ob.@Facets[n50].GetType() == typeof(System.Xml.Schema.XmlSchemaPatternFacet)) {
1086                                                 WriteObject_XmlSchemaPatternFacet (((System.Xml.Schema.XmlSchemaPatternFacet) ob.@Facets[n50]), "pattern", "http://www.w3.org/2001/XMLSchema", false, false, true);
1087                                         }
1088                                         else throw CreateUnknownTypeException (ob.@Facets[n50]);
1089                                 }
1090                         }
1091                         if (writeWrappingElem) WriteEndElement (ob);
1092                 }
1093 /*
1094                 void WriteObject_XmlSchemaUse (System.Xml.Schema.XmlSchemaUse ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1095                 {
1096                         System.Type type = ob.GetType ();
1097                         if (type == typeof(System.Xml.Schema.XmlSchemaUse))
1098                                 ;
1099                         else {
1100                                 throw CreateUnknownTypeException (ob);
1101                         }
1102
1103                         if (writeWrappingElem) {
1104                                 WriteStartElement (element, namesp, ob);
1105                         }
1106
1107                         if (needType) WriteXsiType("XmlSchemaUse", "");
1108
1109                         Writer.WriteString (GetEnumValue_XmlSchemaUse (ob));
1110                         if (writeWrappingElem) WriteEndElement (ob);
1111                 }
1112 */
1113                 string GetEnumValue_XmlSchemaUse (System.Xml.Schema.XmlSchemaUse val)
1114                 {
1115                         switch (val)
1116                         {
1117                                 case System.Xml.Schema.XmlSchemaUse.Optional: return "optional";
1118                                 case System.Xml.Schema.XmlSchemaUse.Prohibited: return "prohibited";
1119                                 case System.Xml.Schema.XmlSchemaUse.Required: return "required";
1120                                 default: return ((long)val).ToString(CultureInfo.InvariantCulture);
1121                         }
1122                 }
1123
1124                 void WriteObject_XmlSchemaAppInfo (System.Xml.Schema.XmlSchemaAppInfo ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1125                 {
1126                         if (ob == null)
1127                         {
1128                                 if (isNullable)
1129                                         WriteNullTagLiteral(element, namesp);
1130                                 return;
1131                         }
1132
1133                         System.Type type = ob.GetType ();
1134                         if (type == typeof(System.Xml.Schema.XmlSchemaAppInfo))
1135                                 ;
1136                         else {
1137                                 throw CreateUnknownTypeException (ob);
1138                         }
1139
1140                         if (writeWrappingElem) {
1141                                 WriteStartElement (element, namesp, ob);
1142                         }
1143
1144                         if (needType) WriteXsiType("XmlSchemaAppInfo", "http://www.w3.org/2001/XMLSchema");
1145
1146                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1147
1148                         WriteAttribute ("source", "", ob.@Source);
1149
1150                         if (ob.@Markup != null) {
1151                                 foreach (XmlNode o51 in ob.@Markup) {
1152                                         XmlNode o52 = o51;
1153                                         if (o52 is XmlElement) {
1154                                                 WriteElementLiteral (o52, "", "", false, true);
1155                                         } else o52.WriteTo (Writer);
1156                                 }
1157                         }
1158                         if (writeWrappingElem) WriteEndElement (ob);
1159                 }
1160
1161                 void WriteObject_XmlSchemaDocumentation (System.Xml.Schema.XmlSchemaDocumentation ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1162                 {
1163                         if (ob == null)
1164                         {
1165                                 if (isNullable)
1166                                         WriteNullTagLiteral(element, namesp);
1167                                 return;
1168                         }
1169
1170                         System.Type type = ob.GetType ();
1171                         if (type == typeof(System.Xml.Schema.XmlSchemaDocumentation))
1172                                 ;
1173                         else {
1174                                 throw CreateUnknownTypeException (ob);
1175                         }
1176
1177                         if (writeWrappingElem) {
1178                                 WriteStartElement (element, namesp, ob);
1179                         }
1180
1181                         if (needType) WriteXsiType("XmlSchemaDocumentation", "http://www.w3.org/2001/XMLSchema");
1182
1183                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1184
1185                         WriteAttribute ("source", "", ob.@Source);
1186                         WriteAttribute ("xml:lang", "", ob.@Language);
1187
1188                         if (ob.@Markup != null) {
1189                                 foreach (XmlNode o53 in ob.@Markup) {
1190                                         XmlNode o54 = o53;
1191                                         if (o54 is XmlElement) {
1192                                                 WriteElementLiteral (o54, "", "", false, true);
1193                                         } else o54.WriteTo (Writer);
1194                                 }
1195                         }
1196                         if (writeWrappingElem) WriteEndElement (ob);
1197                 }
1198
1199                 void WriteObject_XmlSchemaAttributeGroupRef (System.Xml.Schema.XmlSchemaAttributeGroupRef ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1200                 {
1201                         if (ob == null)
1202                         {
1203                                 if (isNullable)
1204                                         WriteNullTagLiteral(element, namesp);
1205                                 return;
1206                         }
1207
1208                         System.Type type = ob.GetType ();
1209                         if (type == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef))
1210                                 ;
1211                         else {
1212                                 throw CreateUnknownTypeException (ob);
1213                         }
1214
1215                         if (writeWrappingElem) {
1216                                 WriteStartElement (element, namesp, ob);
1217                         }
1218
1219                         if (needType) WriteXsiType("XmlSchemaAttributeGroupRef", "http://www.w3.org/2001/XMLSchema");
1220
1221                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1222
1223                         ICollection o55 = ob.@UnhandledAttributes;
1224                         if (o55 != null) {
1225                                 foreach (XmlAttribute o56 in o55)
1226                                         if (o56.NamespaceURI != xmlNamespace)
1227                                                 WriteXmlAttribute (o56, ob);
1228                         }
1229
1230                         WriteAttribute ("id", "", ob.@Id);
1231                         WriteAttribute ("ref", "", FromXmlQualifiedName (ob.@RefName));
1232
1233                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1234                         if (writeWrappingElem) WriteEndElement (ob);
1235                 }
1236
1237                 void WriteObject_XmlSchemaAnyAttribute (System.Xml.Schema.XmlSchemaAnyAttribute ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1238                 {
1239                         if (ob == null)
1240                         {
1241                                 if (isNullable)
1242                                         WriteNullTagLiteral(element, namesp);
1243                                 return;
1244                         }
1245
1246                         System.Type type = ob.GetType ();
1247                         if (type == typeof(System.Xml.Schema.XmlSchemaAnyAttribute))
1248                                 ;
1249                         else {
1250                                 throw CreateUnknownTypeException (ob);
1251                         }
1252
1253                         if (writeWrappingElem) {
1254                                 WriteStartElement (element, namesp, ob);
1255                         }
1256
1257                         if (needType) WriteXsiType("XmlSchemaAnyAttribute", "http://www.w3.org/2001/XMLSchema");
1258
1259                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1260
1261                         ICollection o57 = ob.@UnhandledAttributes;
1262                         if (o57 != null) {
1263                                 foreach (XmlAttribute o58 in o57)
1264                                         if (o58.NamespaceURI != xmlNamespace)
1265                                                 WriteXmlAttribute (o58, ob);
1266                         }
1267
1268                         WriteAttribute ("id", "", ob.@Id);
1269                         WriteAttribute ("namespace", "", ob.@Namespace);
1270                         if (ob.@ProcessContents != ((System.Xml.Schema.XmlSchemaContentProcessing) System.Xml.Schema.XmlSchemaContentProcessing.None)) {
1271                                 WriteAttribute ("processContents", "", GetEnumValue_XmlSchemaContentProcessing (ob.@ProcessContents));
1272                         }
1273
1274                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1275                         if (writeWrappingElem) WriteEndElement (ob);
1276                 }
1277
1278                 void WriteObject_XmlSchemaSequence (System.Xml.Schema.XmlSchemaSequence ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1279                 {
1280                         if (ob == null)
1281                         {
1282                                 if (isNullable)
1283                                         WriteNullTagLiteral(element, namesp);
1284                                 return;
1285                         }
1286
1287                         System.Type type = ob.GetType ();
1288                         if (type == typeof(System.Xml.Schema.XmlSchemaSequence))
1289                                 ;
1290                         else {
1291                                 throw CreateUnknownTypeException (ob);
1292                         }
1293
1294                         if (writeWrappingElem) {
1295                                 WriteStartElement (element, namesp, ob);
1296                         }
1297
1298                         if (needType) WriteXsiType("XmlSchemaSequence", "http://www.w3.org/2001/XMLSchema");
1299
1300                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1301
1302                         ICollection o59 = ob.@UnhandledAttributes;
1303                         if (o59 != null) {
1304                                 foreach (XmlAttribute o60 in o59)
1305                                         if (o60.NamespaceURI != xmlNamespace)
1306                                                 WriteXmlAttribute (o60, ob);
1307                         }
1308
1309                         WriteAttribute ("id", "", ob.@Id);
1310                         WriteAttribute ("minOccurs", "", ob.@MinOccursString);
1311                         WriteAttribute ("maxOccurs", "", ob.@MaxOccursString);
1312
1313                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1314                         if (ob.@Items != null) {
1315                                 for (int n61 = 0; n61 < ob.@Items.Count; n61++) {
1316                                         if (ob.@Items[n61] == null) { }
1317                                         else if (ob.@Items[n61].GetType() == typeof(System.Xml.Schema.XmlSchemaSequence)) {
1318                                                 WriteObject_XmlSchemaSequence (((System.Xml.Schema.XmlSchemaSequence) ob.@Items[n61]), "sequence", "http://www.w3.org/2001/XMLSchema", false, false, true);
1319                                         }
1320                                         else if (ob.@Items[n61].GetType() == typeof(System.Xml.Schema.XmlSchemaChoice)) {
1321                                                 WriteObject_XmlSchemaChoice (((System.Xml.Schema.XmlSchemaChoice) ob.@Items[n61]), "choice", "http://www.w3.org/2001/XMLSchema", false, false, true);
1322                                         }
1323                                         else if (ob.@Items[n61].GetType() == typeof(System.Xml.Schema.XmlSchemaGroupRef)) {
1324                                                 WriteObject_XmlSchemaGroupRef (((System.Xml.Schema.XmlSchemaGroupRef) ob.@Items[n61]), "group", "http://www.w3.org/2001/XMLSchema", false, false, true);
1325                                         }
1326                                         else if (ob.@Items[n61].GetType() == typeof(System.Xml.Schema.XmlSchemaElement)) {
1327                                                 WriteObject_XmlSchemaElement (((System.Xml.Schema.XmlSchemaElement) ob.@Items[n61]), "element", "http://www.w3.org/2001/XMLSchema", false, false, true);
1328                                         }
1329                                         else if (ob.@Items[n61].GetType() == typeof(System.Xml.Schema.XmlSchemaAny)) {
1330                                                 WriteObject_XmlSchemaAny (((System.Xml.Schema.XmlSchemaAny) ob.@Items[n61]), "any", "http://www.w3.org/2001/XMLSchema", false, false, true);
1331                                         }
1332                                         else throw CreateUnknownTypeException (ob.@Items[n61]);
1333                                 }
1334                         }
1335                         if (writeWrappingElem) WriteEndElement (ob);
1336                 }
1337
1338                 void WriteObject_XmlSchemaChoice (System.Xml.Schema.XmlSchemaChoice ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1339                 {
1340                         if (ob == null)
1341                         {
1342                                 if (isNullable)
1343                                         WriteNullTagLiteral(element, namesp);
1344                                 return;
1345                         }
1346
1347                         System.Type type = ob.GetType ();
1348                         if (type == typeof(System.Xml.Schema.XmlSchemaChoice))
1349                                 ;
1350                         else {
1351                                 throw CreateUnknownTypeException (ob);
1352                         }
1353
1354                         if (writeWrappingElem) {
1355                                 WriteStartElement (element, namesp, ob);
1356                         }
1357
1358                         if (needType) WriteXsiType("XmlSchemaChoice", "http://www.w3.org/2001/XMLSchema");
1359
1360                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1361
1362                         ICollection o62 = ob.@UnhandledAttributes;
1363                         if (o62 != null) {
1364                                 foreach (XmlAttribute o63 in o62)
1365                                         if (o63.NamespaceURI != xmlNamespace)
1366                                                 WriteXmlAttribute (o63, ob);
1367                         }
1368
1369                         WriteAttribute ("id", "", ob.@Id);
1370                         WriteAttribute ("minOccurs", "", ob.@MinOccursString);
1371                         WriteAttribute ("maxOccurs", "", ob.@MaxOccursString);
1372
1373                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1374                         if (ob.@Items != null) {
1375                                 for (int n64 = 0; n64 < ob.@Items.Count; n64++) {
1376                                         if (ob.@Items[n64] == null) { }
1377                                         else if (ob.@Items[n64].GetType() == typeof(System.Xml.Schema.XmlSchemaGroupRef)) {
1378                                                 WriteObject_XmlSchemaGroupRef (((System.Xml.Schema.XmlSchemaGroupRef) ob.@Items[n64]), "group", "http://www.w3.org/2001/XMLSchema", false, false, true);
1379                                         }
1380                                         else if (ob.@Items[n64].GetType() == typeof(System.Xml.Schema.XmlSchemaElement)) {
1381                                                 WriteObject_XmlSchemaElement (((System.Xml.Schema.XmlSchemaElement) ob.@Items[n64]), "element", "http://www.w3.org/2001/XMLSchema", false, false, true);
1382                                         }
1383                                         else if (ob.@Items[n64].GetType() == typeof(System.Xml.Schema.XmlSchemaAny)) {
1384                                                 WriteObject_XmlSchemaAny (((System.Xml.Schema.XmlSchemaAny) ob.@Items[n64]), "any", "http://www.w3.org/2001/XMLSchema", false, false, true);
1385                                         }
1386                                         else if (ob.@Items[n64].GetType() == typeof(System.Xml.Schema.XmlSchemaSequence)) {
1387                                                 WriteObject_XmlSchemaSequence (((System.Xml.Schema.XmlSchemaSequence) ob.@Items[n64]), "sequence", "http://www.w3.org/2001/XMLSchema", false, false, true);
1388                                         }
1389                                         else if (ob.@Items[n64].GetType() == typeof(System.Xml.Schema.XmlSchemaChoice)) {
1390                                                 WriteObject_XmlSchemaChoice (((System.Xml.Schema.XmlSchemaChoice) ob.@Items[n64]), "choice", "http://www.w3.org/2001/XMLSchema", false, false, true);
1391                                         }
1392                                         else throw CreateUnknownTypeException (ob.@Items[n64]);
1393                                 }
1394                         }
1395                         if (writeWrappingElem) WriteEndElement (ob);
1396                 }
1397
1398                 void WriteObject_XmlSchemaAll (System.Xml.Schema.XmlSchemaAll ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1399                 {
1400                         if (ob == null)
1401                         {
1402                                 if (isNullable)
1403                                         WriteNullTagLiteral(element, namesp);
1404                                 return;
1405                         }
1406
1407                         System.Type type = ob.GetType ();
1408                         if (type == typeof(System.Xml.Schema.XmlSchemaAll))
1409                                 ;
1410                         else {
1411                                 throw CreateUnknownTypeException (ob);
1412                         }
1413
1414                         if (writeWrappingElem) {
1415                                 WriteStartElement (element, namesp, ob);
1416                         }
1417
1418                         if (needType) WriteXsiType("XmlSchemaAll", "http://www.w3.org/2001/XMLSchema");
1419
1420                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1421
1422                         ICollection o65 = ob.@UnhandledAttributes;
1423                         if (o65 != null) {
1424                                 foreach (XmlAttribute o66 in o65)
1425                                         if (o66.NamespaceURI != xmlNamespace)
1426                                                 WriteXmlAttribute (o66, ob);
1427                         }
1428
1429                         WriteAttribute ("id", "", ob.@Id);
1430                         WriteAttribute ("minOccurs", "", ob.@MinOccursString);
1431                         WriteAttribute ("maxOccurs", "", ob.@MaxOccursString);
1432
1433                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1434                         if (ob.@Items != null) {
1435                                 for (int n67 = 0; n67 < ob.@Items.Count; n67++) {
1436                                         WriteObject_XmlSchemaElement (((System.Xml.Schema.XmlSchemaElement) ob.@Items[n67]), "element", "http://www.w3.org/2001/XMLSchema", false, false, true);
1437                                 }
1438                         }
1439                         if (writeWrappingElem) WriteEndElement (ob);
1440                 }
1441
1442                 void WriteObject_XmlSchemaComplexContent (System.Xml.Schema.XmlSchemaComplexContent ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1443                 {
1444                         if (ob == null)
1445                         {
1446                                 if (isNullable)
1447                                         WriteNullTagLiteral(element, namesp);
1448                                 return;
1449                         }
1450
1451                         System.Type type = ob.GetType ();
1452                         if (type == typeof(System.Xml.Schema.XmlSchemaComplexContent))
1453                                 ;
1454                         else {
1455                                 throw CreateUnknownTypeException (ob);
1456                         }
1457
1458                         if (writeWrappingElem) {
1459                                 WriteStartElement (element, namesp, ob);
1460                         }
1461
1462                         if (needType) WriteXsiType("XmlSchemaComplexContent", "http://www.w3.org/2001/XMLSchema");
1463
1464                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1465
1466                         ICollection o68 = ob.@UnhandledAttributes;
1467                         if (o68 != null) {
1468                                 foreach (XmlAttribute o69 in o68)
1469                                         if (o69.NamespaceURI != xmlNamespace)
1470                                                 WriteXmlAttribute (o69, ob);
1471                         }
1472
1473                         WriteAttribute ("id", "", ob.@Id);
1474                         WriteAttribute ("mixed", "", (ob.@IsMixed?"true":"false"));
1475
1476                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1477                         if (ob.@Content is System.Xml.Schema.XmlSchemaComplexContentExtension) {
1478                                 WriteObject_XmlSchemaComplexContentExtension (((System.Xml.Schema.XmlSchemaComplexContentExtension) ob.@Content), "extension", "http://www.w3.org/2001/XMLSchema", false, false, true);
1479                         }
1480                         else if (ob.@Content is System.Xml.Schema.XmlSchemaComplexContentRestriction) {
1481                                 WriteObject_XmlSchemaComplexContentRestriction (((System.Xml.Schema.XmlSchemaComplexContentRestriction) ob.@Content), "restriction", "http://www.w3.org/2001/XMLSchema", false, false, true);
1482                         }
1483                         if (writeWrappingElem) WriteEndElement (ob);
1484                 }
1485
1486                 void WriteObject_XmlSchemaSimpleContent (System.Xml.Schema.XmlSchemaSimpleContent ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1487                 {
1488                         if (ob == null)
1489                         {
1490                                 if (isNullable)
1491                                         WriteNullTagLiteral(element, namesp);
1492                                 return;
1493                         }
1494
1495                         System.Type type = ob.GetType ();
1496                         if (type == typeof(System.Xml.Schema.XmlSchemaSimpleContent))
1497                                 ;
1498                         else {
1499                                 throw CreateUnknownTypeException (ob);
1500                         }
1501
1502                         if (writeWrappingElem) {
1503                                 WriteStartElement (element, namesp, ob);
1504                         }
1505
1506                         if (needType) WriteXsiType("XmlSchemaSimpleContent", "http://www.w3.org/2001/XMLSchema");
1507
1508                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1509
1510                         ICollection o70 = ob.@UnhandledAttributes;
1511                         if (o70 != null) {
1512                                 foreach (XmlAttribute o71 in o70)
1513                                         if (o71.NamespaceURI != xmlNamespace)
1514                                                 WriteXmlAttribute (o71, ob);
1515                         }
1516
1517                         WriteAttribute ("id", "", ob.@Id);
1518
1519                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1520                         if (ob.@Content is System.Xml.Schema.XmlSchemaSimpleContentExtension) {
1521                                 WriteObject_XmlSchemaSimpleContentExtension (((System.Xml.Schema.XmlSchemaSimpleContentExtension) ob.@Content), "extension", "http://www.w3.org/2001/XMLSchema", false, false, true);
1522                         }
1523                         else if (ob.@Content is System.Xml.Schema.XmlSchemaSimpleContentRestriction) {
1524                                 WriteObject_XmlSchemaSimpleContentRestriction (((System.Xml.Schema.XmlSchemaSimpleContentRestriction) ob.@Content), "restriction", "http://www.w3.org/2001/XMLSchema", false, false, true);
1525                         }
1526                         if (writeWrappingElem) WriteEndElement (ob);
1527                 }
1528
1529                 void WriteObject_XmlSchemaGroupRef (System.Xml.Schema.XmlSchemaGroupRef ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1530                 {
1531                         if (ob == null)
1532                         {
1533                                 if (isNullable)
1534                                         WriteNullTagLiteral(element, namesp);
1535                                 return;
1536                         }
1537
1538                         System.Type type = ob.GetType ();
1539                         if (type == typeof(System.Xml.Schema.XmlSchemaGroupRef))
1540                                 ;
1541                         else {
1542                                 throw CreateUnknownTypeException (ob);
1543                         }
1544
1545                         if (writeWrappingElem) {
1546                                 WriteStartElement (element, namesp, ob);
1547                         }
1548
1549                         if (needType) WriteXsiType("XmlSchemaGroupRef", "http://www.w3.org/2001/XMLSchema");
1550
1551                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1552
1553                         ICollection o72 = ob.@UnhandledAttributes;
1554                         if (o72 != null) {
1555                                 foreach (XmlAttribute o73 in o72)
1556                                         if (o73.NamespaceURI != xmlNamespace)
1557                                                 WriteXmlAttribute (o73, ob);
1558                         }
1559
1560                         WriteAttribute ("id", "", ob.@Id);
1561                         WriteAttribute ("minOccurs", "", ob.@MinOccursString);
1562                         WriteAttribute ("maxOccurs", "", ob.@MaxOccursString);
1563                         WriteAttribute ("ref", "", FromXmlQualifiedName (ob.@RefName));
1564
1565                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1566                         if (writeWrappingElem) WriteEndElement (ob);
1567                 }
1568
1569                 void WriteObject_XmlSchemaXPath (System.Xml.Schema.XmlSchemaXPath ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1570                 {
1571                         if (ob == null)
1572                         {
1573                                 if (isNullable)
1574                                         WriteNullTagLiteral(element, namesp);
1575                                 return;
1576                         }
1577
1578                         System.Type type = ob.GetType ();
1579                         if (type == typeof(System.Xml.Schema.XmlSchemaXPath))
1580                                 ;
1581                         else {
1582                                 throw CreateUnknownTypeException (ob);
1583                         }
1584
1585                         if (writeWrappingElem) {
1586                                 WriteStartElement (element, namesp, ob);
1587                         }
1588
1589                         if (needType) WriteXsiType("XmlSchemaXPath", "http://www.w3.org/2001/XMLSchema");
1590
1591                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1592
1593                         ICollection o74 = ob.@UnhandledAttributes;
1594                         if (o74 != null) {
1595                                 foreach (XmlAttribute o75 in o74)
1596                                         if (o75.NamespaceURI != xmlNamespace)
1597                                                 WriteXmlAttribute (o75, ob);
1598                         }
1599
1600                         WriteAttribute ("id", "", ob.@Id);
1601                         if (ob.@XPath != null) {
1602                                 WriteAttribute ("xpath", "", ob.@XPath);
1603                         }
1604
1605                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1606                         if (writeWrappingElem) WriteEndElement (ob);
1607                 }
1608
1609                 void WriteObject_XmlSchemaMaxLengthFacet (System.Xml.Schema.XmlSchemaMaxLengthFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1610                 {
1611                         if (ob == null)
1612                         {
1613                                 if (isNullable)
1614                                         WriteNullTagLiteral(element, namesp);
1615                                 return;
1616                         }
1617
1618                         System.Type type = ob.GetType ();
1619                         if (type == typeof(System.Xml.Schema.XmlSchemaMaxLengthFacet))
1620                                 ;
1621                         else {
1622                                 throw CreateUnknownTypeException (ob);
1623                         }
1624
1625                         if (writeWrappingElem) {
1626                                 WriteStartElement (element, namesp, ob);
1627                         }
1628
1629                         if (needType) WriteXsiType("XmlSchemaMaxLengthFacet", "http://www.w3.org/2001/XMLSchema");
1630
1631                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1632
1633                         ICollection o76 = ob.@UnhandledAttributes;
1634                         if (o76 != null) {
1635                                 foreach (XmlAttribute o77 in o76)
1636                                         if (o77.NamespaceURI != xmlNamespace)
1637                                                 WriteXmlAttribute (o77, ob);
1638                         }
1639
1640                         WriteAttribute ("id", "", ob.@Id);
1641                         WriteAttribute ("value", "", ob.@Value);
1642                         if (ob.@IsFixed != false) {
1643                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1644                         }
1645
1646                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1647                         if (writeWrappingElem) WriteEndElement (ob);
1648                 }
1649
1650                 void WriteObject_XmlSchemaMinLengthFacet (System.Xml.Schema.XmlSchemaMinLengthFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1651                 {
1652                         if (ob == null)
1653                         {
1654                                 if (isNullable)
1655                                         WriteNullTagLiteral(element, namesp);
1656                                 return;
1657                         }
1658
1659                         System.Type type = ob.GetType ();
1660                         if (type == typeof(System.Xml.Schema.XmlSchemaMinLengthFacet))
1661                                 ;
1662                         else {
1663                                 throw CreateUnknownTypeException (ob);
1664                         }
1665
1666                         if (writeWrappingElem) {
1667                                 WriteStartElement (element, namesp, ob);
1668                         }
1669
1670                         if (needType) WriteXsiType("XmlSchemaMinLengthFacet", "http://www.w3.org/2001/XMLSchema");
1671
1672                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1673
1674                         ICollection o78 = ob.@UnhandledAttributes;
1675                         if (o78 != null) {
1676                                 foreach (XmlAttribute o79 in o78)
1677                                         if (o79.NamespaceURI != xmlNamespace)
1678                                                 WriteXmlAttribute (o79, ob);
1679                         }
1680
1681                         WriteAttribute ("id", "", ob.@Id);
1682                         WriteAttribute ("value", "", ob.@Value);
1683                         if (ob.@IsFixed != false) {
1684                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1685                         }
1686
1687                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1688                         if (writeWrappingElem) WriteEndElement (ob);
1689                 }
1690
1691                 void WriteObject_XmlSchemaLengthFacet (System.Xml.Schema.XmlSchemaLengthFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1692                 {
1693                         if (ob == null)
1694                         {
1695                                 if (isNullable)
1696                                         WriteNullTagLiteral(element, namesp);
1697                                 return;
1698                         }
1699
1700                         System.Type type = ob.GetType ();
1701                         if (type == typeof(System.Xml.Schema.XmlSchemaLengthFacet))
1702                                 ;
1703                         else {
1704                                 throw CreateUnknownTypeException (ob);
1705                         }
1706
1707                         if (writeWrappingElem) {
1708                                 WriteStartElement (element, namesp, ob);
1709                         }
1710
1711                         if (needType) WriteXsiType("XmlSchemaLengthFacet", "http://www.w3.org/2001/XMLSchema");
1712
1713                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1714
1715                         ICollection o80 = ob.@UnhandledAttributes;
1716                         if (o80 != null) {
1717                                 foreach (XmlAttribute o81 in o80)
1718                                         if (o81.NamespaceURI != xmlNamespace)
1719                                                 WriteXmlAttribute (o81, ob);
1720                         }
1721
1722                         WriteAttribute ("id", "", ob.@Id);
1723                         WriteAttribute ("value", "", ob.@Value);
1724                         if (ob.@IsFixed != false) {
1725                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1726                         }
1727
1728                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1729                         if (writeWrappingElem) WriteEndElement (ob);
1730                 }
1731
1732                 void WriteObject_XmlSchemaFractionDigitsFacet (System.Xml.Schema.XmlSchemaFractionDigitsFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1733                 {
1734                         if (ob == null)
1735                         {
1736                                 if (isNullable)
1737                                         WriteNullTagLiteral(element, namesp);
1738                                 return;
1739                         }
1740
1741                         System.Type type = ob.GetType ();
1742                         if (type == typeof(System.Xml.Schema.XmlSchemaFractionDigitsFacet))
1743                                 ;
1744                         else {
1745                                 throw CreateUnknownTypeException (ob);
1746                         }
1747
1748                         if (writeWrappingElem) {
1749                                 WriteStartElement (element, namesp, ob);
1750                         }
1751
1752                         if (needType) WriteXsiType("XmlSchemaFractionDigitsFacet", "http://www.w3.org/2001/XMLSchema");
1753
1754                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1755
1756                         ICollection o82 = ob.@UnhandledAttributes;
1757                         if (o82 != null) {
1758                                 foreach (XmlAttribute o83 in o82)
1759                                         if (o83.NamespaceURI != xmlNamespace)
1760                                                 WriteXmlAttribute (o83, ob);
1761                         }
1762
1763                         WriteAttribute ("id", "", ob.@Id);
1764                         WriteAttribute ("value", "", ob.@Value);
1765                         if (ob.@IsFixed != false) {
1766                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1767                         }
1768
1769                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1770                         if (writeWrappingElem) WriteEndElement (ob);
1771                 }
1772
1773                 void WriteObject_XmlSchemaMaxInclusiveFacet (System.Xml.Schema.XmlSchemaMaxInclusiveFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1774                 {
1775                         if (ob == null)
1776                         {
1777                                 if (isNullable)
1778                                         WriteNullTagLiteral(element, namesp);
1779                                 return;
1780                         }
1781
1782                         System.Type type = ob.GetType ();
1783                         if (type == typeof(System.Xml.Schema.XmlSchemaMaxInclusiveFacet))
1784                                 ;
1785                         else {
1786                                 throw CreateUnknownTypeException (ob);
1787                         }
1788
1789                         if (writeWrappingElem) {
1790                                 WriteStartElement (element, namesp, ob);
1791                         }
1792
1793                         if (needType) WriteXsiType("XmlSchemaMaxInclusiveFacet", "http://www.w3.org/2001/XMLSchema");
1794
1795                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1796
1797                         ICollection o84 = ob.@UnhandledAttributes;
1798                         if (o84 != null) {
1799                                 foreach (XmlAttribute o85 in o84)
1800                                         if (o85.NamespaceURI != xmlNamespace)
1801                                                 WriteXmlAttribute (o85, ob);
1802                         }
1803
1804                         WriteAttribute ("id", "", ob.@Id);
1805                         WriteAttribute ("value", "", ob.@Value);
1806                         if (ob.@IsFixed != false) {
1807                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1808                         }
1809
1810                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1811                         if (writeWrappingElem) WriteEndElement (ob);
1812                 }
1813
1814                 void WriteObject_XmlSchemaMaxExclusiveFacet (System.Xml.Schema.XmlSchemaMaxExclusiveFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1815                 {
1816                         if (ob == null)
1817                         {
1818                                 if (isNullable)
1819                                         WriteNullTagLiteral(element, namesp);
1820                                 return;
1821                         }
1822
1823                         System.Type type = ob.GetType ();
1824                         if (type == typeof(System.Xml.Schema.XmlSchemaMaxExclusiveFacet))
1825                                 ;
1826                         else {
1827                                 throw CreateUnknownTypeException (ob);
1828                         }
1829
1830                         if (writeWrappingElem) {
1831                                 WriteStartElement (element, namesp, ob);
1832                         }
1833
1834                         if (needType) WriteXsiType("XmlSchemaMaxExclusiveFacet", "http://www.w3.org/2001/XMLSchema");
1835
1836                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1837
1838                         ICollection o86 = ob.@UnhandledAttributes;
1839                         if (o86 != null) {
1840                                 foreach (XmlAttribute o87 in o86)
1841                                         if (o87.NamespaceURI != xmlNamespace)
1842                                                 WriteXmlAttribute (o87, ob);
1843                         }
1844
1845                         WriteAttribute ("id", "", ob.@Id);
1846                         WriteAttribute ("value", "", ob.@Value);
1847                         if (ob.@IsFixed != false) {
1848                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1849                         }
1850
1851                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1852                         if (writeWrappingElem) WriteEndElement (ob);
1853                 }
1854
1855                 void WriteObject_XmlSchemaMinExclusiveFacet (System.Xml.Schema.XmlSchemaMinExclusiveFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1856                 {
1857                         if (ob == null)
1858                         {
1859                                 if (isNullable)
1860                                         WriteNullTagLiteral(element, namesp);
1861                                 return;
1862                         }
1863
1864                         System.Type type = ob.GetType ();
1865                         if (type == typeof(System.Xml.Schema.XmlSchemaMinExclusiveFacet))
1866                                 ;
1867                         else {
1868                                 throw CreateUnknownTypeException (ob);
1869                         }
1870
1871                         if (writeWrappingElem) {
1872                                 WriteStartElement (element, namesp, ob);
1873                         }
1874
1875                         if (needType) WriteXsiType("XmlSchemaMinExclusiveFacet", "http://www.w3.org/2001/XMLSchema");
1876
1877                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1878
1879                         ICollection o88 = ob.@UnhandledAttributes;
1880                         if (o88 != null) {
1881                                 foreach (XmlAttribute o89 in o88)
1882                                         if (o89.NamespaceURI != xmlNamespace)
1883                                                 WriteXmlAttribute (o89, ob);
1884                         }
1885
1886                         WriteAttribute ("id", "", ob.@Id);
1887                         WriteAttribute ("value", "", ob.@Value);
1888                         if (ob.@IsFixed != false) {
1889                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1890                         }
1891
1892                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1893                         if (writeWrappingElem) WriteEndElement (ob);
1894                 }
1895
1896                 void WriteObject_XmlSchemaEnumerationFacet (System.Xml.Schema.XmlSchemaEnumerationFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1897                 {
1898                         if (ob == null)
1899                         {
1900                                 if (isNullable)
1901                                         WriteNullTagLiteral(element, namesp);
1902                                 return;
1903                         }
1904
1905                         System.Type type = ob.GetType ();
1906                         if (type == typeof(System.Xml.Schema.XmlSchemaEnumerationFacet))
1907                                 ;
1908                         else {
1909                                 throw CreateUnknownTypeException (ob);
1910                         }
1911
1912                         if (writeWrappingElem) {
1913                                 WriteStartElement (element, namesp, ob);
1914                         }
1915
1916                         if (needType) WriteXsiType("XmlSchemaEnumerationFacet", "http://www.w3.org/2001/XMLSchema");
1917
1918                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1919
1920                         ICollection o90 = ob.@UnhandledAttributes;
1921                         if (o90 != null) {
1922                                 foreach (XmlAttribute o91 in o90)
1923                                         if (o91.NamespaceURI != xmlNamespace)
1924                                                 WriteXmlAttribute (o91, ob);
1925                         }
1926
1927                         WriteAttribute ("id", "", ob.@Id);
1928                         WriteAttribute ("value", "", ob.@Value);
1929                         if (ob.@IsFixed != false) {
1930                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1931                         }
1932
1933                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1934                         if (writeWrappingElem) WriteEndElement (ob);
1935                 }
1936
1937                 void WriteObject_XmlSchemaTotalDigitsFacet (System.Xml.Schema.XmlSchemaTotalDigitsFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1938                 {
1939                         if (ob == null)
1940                         {
1941                                 if (isNullable)
1942                                         WriteNullTagLiteral(element, namesp);
1943                                 return;
1944                         }
1945
1946                         System.Type type = ob.GetType ();
1947                         if (type == typeof(System.Xml.Schema.XmlSchemaTotalDigitsFacet))
1948                                 ;
1949                         else {
1950                                 throw CreateUnknownTypeException (ob);
1951                         }
1952
1953                         if (writeWrappingElem) {
1954                                 WriteStartElement (element, namesp, ob);
1955                         }
1956
1957                         if (needType) WriteXsiType("XmlSchemaTotalDigitsFacet", "http://www.w3.org/2001/XMLSchema");
1958
1959                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
1960
1961                         ICollection o92 = ob.@UnhandledAttributes;
1962                         if (o92 != null) {
1963                                 foreach (XmlAttribute o93 in o92)
1964                                         if (o93.NamespaceURI != xmlNamespace)
1965                                                 WriteXmlAttribute (o93, ob);
1966                         }
1967
1968                         WriteAttribute ("id", "", ob.@Id);
1969                         WriteAttribute ("value", "", ob.@Value);
1970                         if (ob.@IsFixed != false) {
1971                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
1972                         }
1973
1974                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
1975                         if (writeWrappingElem) WriteEndElement (ob);
1976                 }
1977
1978                 void WriteObject_XmlSchemaMinInclusiveFacet (System.Xml.Schema.XmlSchemaMinInclusiveFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
1979                 {
1980                         if (ob == null)
1981                         {
1982                                 if (isNullable)
1983                                         WriteNullTagLiteral(element, namesp);
1984                                 return;
1985                         }
1986
1987                         System.Type type = ob.GetType ();
1988                         if (type == typeof(System.Xml.Schema.XmlSchemaMinInclusiveFacet))
1989                                 ;
1990                         else {
1991                                 throw CreateUnknownTypeException (ob);
1992                         }
1993
1994                         if (writeWrappingElem) {
1995                                 WriteStartElement (element, namesp, ob);
1996                         }
1997
1998                         if (needType) WriteXsiType("XmlSchemaMinInclusiveFacet", "http://www.w3.org/2001/XMLSchema");
1999
2000                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2001
2002                         ICollection o94 = ob.@UnhandledAttributes;
2003                         if (o94 != null) {
2004                                 foreach (XmlAttribute o95 in o94)
2005                                         if (o95.NamespaceURI != xmlNamespace)
2006                                                 WriteXmlAttribute (o95, ob);
2007                         }
2008
2009                         WriteAttribute ("id", "", ob.@Id);
2010                         WriteAttribute ("value", "", ob.@Value);
2011                         if (ob.@IsFixed != false) {
2012                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
2013                         }
2014
2015                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2016                         if (writeWrappingElem) WriteEndElement (ob);
2017                 }
2018
2019                 void WriteObject_XmlSchemaWhiteSpaceFacet (System.Xml.Schema.XmlSchemaWhiteSpaceFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2020                 {
2021                         if (ob == null)
2022                         {
2023                                 if (isNullable)
2024                                         WriteNullTagLiteral(element, namesp);
2025                                 return;
2026                         }
2027
2028                         System.Type type = ob.GetType ();
2029                         if (type == typeof(System.Xml.Schema.XmlSchemaWhiteSpaceFacet))
2030                                 ;
2031                         else {
2032                                 throw CreateUnknownTypeException (ob);
2033                         }
2034
2035                         if (writeWrappingElem) {
2036                                 WriteStartElement (element, namesp, ob);
2037                         }
2038
2039                         if (needType) WriteXsiType("XmlSchemaWhiteSpaceFacet", "http://www.w3.org/2001/XMLSchema");
2040
2041                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2042
2043                         ICollection o96 = ob.@UnhandledAttributes;
2044                         if (o96 != null) {
2045                                 foreach (XmlAttribute o97 in o96)
2046                                         if (o97.NamespaceURI != xmlNamespace)
2047                                                 WriteXmlAttribute (o97, ob);
2048                         }
2049
2050                         WriteAttribute ("id", "", ob.@Id);
2051                         WriteAttribute ("value", "", ob.@Value);
2052                         if (ob.@IsFixed != false) {
2053                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
2054                         }
2055
2056                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2057                         if (writeWrappingElem) WriteEndElement (ob);
2058                 }
2059
2060                 void WriteObject_XmlSchemaPatternFacet (System.Xml.Schema.XmlSchemaPatternFacet ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2061                 {
2062                         if (ob == null)
2063                         {
2064                                 if (isNullable)
2065                                         WriteNullTagLiteral(element, namesp);
2066                                 return;
2067                         }
2068
2069                         System.Type type = ob.GetType ();
2070                         if (type == typeof(System.Xml.Schema.XmlSchemaPatternFacet))
2071                                 ;
2072                         else {
2073                                 throw CreateUnknownTypeException (ob);
2074                         }
2075
2076                         if (writeWrappingElem) {
2077                                 WriteStartElement (element, namesp, ob);
2078                         }
2079
2080                         if (needType) WriteXsiType("XmlSchemaPatternFacet", "http://www.w3.org/2001/XMLSchema");
2081
2082                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2083
2084                         ICollection o98 = ob.@UnhandledAttributes;
2085                         if (o98 != null) {
2086                                 foreach (XmlAttribute o99 in o98)
2087                                         if (o99.NamespaceURI != xmlNamespace)
2088                                                 WriteXmlAttribute (o99, ob);
2089                         }
2090
2091                         WriteAttribute ("id", "", ob.@Id);
2092                         WriteAttribute ("value", "", ob.@Value);
2093                         if (ob.@IsFixed != false) {
2094                                 WriteAttribute ("fixed", "", (ob.@IsFixed?"true":"false"));
2095                         }
2096
2097                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2098                         if (writeWrappingElem) WriteEndElement (ob);
2099                 }
2100 /*
2101                 void WriteObject_XmlSchemaContentProcessing (System.Xml.Schema.XmlSchemaContentProcessing ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2102                 {
2103                         System.Type type = ob.GetType ();
2104                         if (type == typeof(System.Xml.Schema.XmlSchemaContentProcessing))
2105                                 ;
2106                         else {
2107                                 throw CreateUnknownTypeException (ob);
2108                         }
2109
2110                         if (writeWrappingElem) {
2111                                 WriteStartElement (element, namesp, ob);
2112                         }
2113
2114                         if (needType) WriteXsiType("XmlSchemaContentProcessing", "");
2115
2116                         Writer.WriteString (GetEnumValue_XmlSchemaContentProcessing (ob));
2117                         if (writeWrappingElem) WriteEndElement (ob);
2118                 }
2119 */
2120                 string GetEnumValue_XmlSchemaContentProcessing (System.Xml.Schema.XmlSchemaContentProcessing val)
2121                 {
2122                         switch (val)
2123                         {
2124                                 case System.Xml.Schema.XmlSchemaContentProcessing.Skip: return "skip";
2125                                 case System.Xml.Schema.XmlSchemaContentProcessing.Lax: return "lax";
2126                                 case System.Xml.Schema.XmlSchemaContentProcessing.Strict: return "strict";
2127                                 default: return ((long)val).ToString(CultureInfo.InvariantCulture);
2128                         }
2129                 }
2130
2131                 void WriteObject_XmlSchemaAny (System.Xml.Schema.XmlSchemaAny ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2132                 {
2133                         if (ob == null)
2134                         {
2135                                 if (isNullable)
2136                                         WriteNullTagLiteral(element, namesp);
2137                                 return;
2138                         }
2139
2140                         System.Type type = ob.GetType ();
2141                         if (type == typeof(System.Xml.Schema.XmlSchemaAny))
2142                                 ;
2143                         else {
2144                                 throw CreateUnknownTypeException (ob);
2145                         }
2146
2147                         if (writeWrappingElem) {
2148                                 WriteStartElement (element, namesp, ob);
2149                         }
2150
2151                         if (needType) WriteXsiType("XmlSchemaAny", "http://www.w3.org/2001/XMLSchema");
2152
2153                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2154
2155                         ICollection o100 = ob.@UnhandledAttributes;
2156                         if (o100 != null) {
2157                                 foreach (XmlAttribute o101 in o100)
2158                                         if (o101.NamespaceURI != xmlNamespace)
2159                                                 WriteXmlAttribute (o101, ob);
2160                         }
2161
2162                         WriteAttribute ("id", "", ob.@Id);
2163                         WriteAttribute ("minOccurs", "", ob.@MinOccursString);
2164                         WriteAttribute ("maxOccurs", "", ob.@MaxOccursString);
2165                         WriteAttribute ("namespace", "", ob.@Namespace);
2166                         if (ob.@ProcessContents != ((System.Xml.Schema.XmlSchemaContentProcessing) System.Xml.Schema.XmlSchemaContentProcessing.None)) {
2167                                 WriteAttribute ("processContents", "", GetEnumValue_XmlSchemaContentProcessing (ob.@ProcessContents));
2168                         }
2169
2170                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2171                         if (writeWrappingElem) WriteEndElement (ob);
2172                 }
2173
2174                 void WriteObject_XmlSchemaComplexContentExtension (System.Xml.Schema.XmlSchemaComplexContentExtension ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2175                 {
2176                         if (ob == null)
2177                         {
2178                                 if (isNullable)
2179                                         WriteNullTagLiteral(element, namesp);
2180                                 return;
2181                         }
2182
2183                         System.Type type = ob.GetType ();
2184                         if (type == typeof(System.Xml.Schema.XmlSchemaComplexContentExtension))
2185                                 ;
2186                         else {
2187                                 throw CreateUnknownTypeException (ob);
2188                         }
2189
2190                         if (writeWrappingElem) {
2191                                 WriteStartElement (element, namesp, ob);
2192                         }
2193
2194                         if (needType) WriteXsiType("XmlSchemaComplexContentExtension", "http://www.w3.org/2001/XMLSchema");
2195
2196                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2197
2198                         ICollection o102 = ob.@UnhandledAttributes;
2199                         if (o102 != null) {
2200                                 foreach (XmlAttribute o103 in o102)
2201                                         if (o103.NamespaceURI != xmlNamespace)
2202                                                 WriteXmlAttribute (o103, ob);
2203                         }
2204
2205                         WriteAttribute ("id", "", ob.@Id);
2206                         WriteAttribute ("base", "", FromXmlQualifiedName (ob.@BaseTypeName));
2207
2208                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2209                         if (ob.@Particle is System.Xml.Schema.XmlSchemaGroupRef) {
2210                                 WriteObject_XmlSchemaGroupRef (((System.Xml.Schema.XmlSchemaGroupRef) ob.@Particle), "group", "http://www.w3.org/2001/XMLSchema", false, false, true);
2211                         }
2212                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaSequence) {
2213                                 WriteObject_XmlSchemaSequence (((System.Xml.Schema.XmlSchemaSequence) ob.@Particle), "sequence", "http://www.w3.org/2001/XMLSchema", false, false, true);
2214                         }
2215                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaChoice) {
2216                                 WriteObject_XmlSchemaChoice (((System.Xml.Schema.XmlSchemaChoice) ob.@Particle), "choice", "http://www.w3.org/2001/XMLSchema", false, false, true);
2217                         }
2218                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaAll) {
2219                                 WriteObject_XmlSchemaAll (((System.Xml.Schema.XmlSchemaAll) ob.@Particle), "all", "http://www.w3.org/2001/XMLSchema", false, false, true);
2220                         }
2221                         if (ob.@Attributes != null) {
2222                                 for (int n104 = 0; n104 < ob.@Attributes.Count; n104++) {
2223                                         if (ob.@Attributes[n104] == null) { }
2224                                         else if (ob.@Attributes[n104].GetType() == typeof(System.Xml.Schema.XmlSchemaAttribute)) {
2225                                                 WriteObject_XmlSchemaAttribute (((System.Xml.Schema.XmlSchemaAttribute) ob.@Attributes[n104]), "attribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2226                                         }
2227                                         else if (ob.@Attributes[n104].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) {
2228                                                 WriteObject_XmlSchemaAttributeGroupRef (((System.Xml.Schema.XmlSchemaAttributeGroupRef) ob.@Attributes[n104]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
2229                                         }
2230                                         else throw CreateUnknownTypeException (ob.@Attributes[n104]);
2231                                 }
2232                         }
2233                         WriteObject_XmlSchemaAnyAttribute (ob.@AnyAttribute, "anyAttribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2234                         if (writeWrappingElem) WriteEndElement (ob);
2235                 }
2236
2237                 void WriteObject_XmlSchemaComplexContentRestriction (System.Xml.Schema.XmlSchemaComplexContentRestriction ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2238                 {
2239                         if (ob == null)
2240                         {
2241                                 if (isNullable)
2242                                         WriteNullTagLiteral(element, namesp);
2243                                 return;
2244                         }
2245
2246                         System.Type type = ob.GetType ();
2247                         if (type == typeof(System.Xml.Schema.XmlSchemaComplexContentRestriction))
2248                                 ;
2249                         else {
2250                                 throw CreateUnknownTypeException (ob);
2251                         }
2252
2253                         if (writeWrappingElem) {
2254                                 WriteStartElement (element, namesp, ob);
2255                         }
2256
2257                         if (needType) WriteXsiType("XmlSchemaComplexContentRestriction", "http://www.w3.org/2001/XMLSchema");
2258
2259                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2260
2261                         ICollection o105 = ob.@UnhandledAttributes;
2262                         if (o105 != null) {
2263                                 foreach (XmlAttribute o106 in o105)
2264                                         if (o106.NamespaceURI != xmlNamespace)
2265                                                 WriteXmlAttribute (o106, ob);
2266                         }
2267
2268                         WriteAttribute ("id", "", ob.@Id);
2269                         WriteAttribute ("base", "", FromXmlQualifiedName (ob.@BaseTypeName));
2270
2271                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2272                         if (ob.@Particle is System.Xml.Schema.XmlSchemaSequence) {
2273                                 WriteObject_XmlSchemaSequence (((System.Xml.Schema.XmlSchemaSequence) ob.@Particle), "sequence", "http://www.w3.org/2001/XMLSchema", false, false, true);
2274                         }
2275                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaChoice) {
2276                                 WriteObject_XmlSchemaChoice (((System.Xml.Schema.XmlSchemaChoice) ob.@Particle), "choice", "http://www.w3.org/2001/XMLSchema", false, false, true);
2277                         }
2278                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaGroupRef) {
2279                                 WriteObject_XmlSchemaGroupRef (((System.Xml.Schema.XmlSchemaGroupRef) ob.@Particle), "group", "http://www.w3.org/2001/XMLSchema", false, false, true);
2280                         }
2281                         else if (ob.@Particle is System.Xml.Schema.XmlSchemaAll) {
2282                                 WriteObject_XmlSchemaAll (((System.Xml.Schema.XmlSchemaAll) ob.@Particle), "all", "http://www.w3.org/2001/XMLSchema", false, false, true);
2283                         }
2284                         if (ob.@Attributes != null) {
2285                                 for (int n107 = 0; n107 < ob.@Attributes.Count; n107++) {
2286                                         if (ob.@Attributes[n107] == null) { }
2287                                         else if (ob.@Attributes[n107].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) {
2288                                                 WriteObject_XmlSchemaAttributeGroupRef (((System.Xml.Schema.XmlSchemaAttributeGroupRef) ob.@Attributes[n107]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
2289                                         }
2290                                         else if (ob.@Attributes[n107].GetType() == typeof(System.Xml.Schema.XmlSchemaAttribute)) {
2291                                                 WriteObject_XmlSchemaAttribute (((System.Xml.Schema.XmlSchemaAttribute) ob.@Attributes[n107]), "attribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2292                                         }
2293                                         else throw CreateUnknownTypeException (ob.@Attributes[n107]);
2294                                 }
2295                         }
2296                         WriteObject_XmlSchemaAnyAttribute (ob.@AnyAttribute, "anyAttribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2297                         if (writeWrappingElem) WriteEndElement (ob);
2298                 }
2299
2300                 void WriteObject_XmlSchemaSimpleContentExtension (System.Xml.Schema.XmlSchemaSimpleContentExtension ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2301                 {
2302                         if (ob == null)
2303                         {
2304                                 if (isNullable)
2305                                         WriteNullTagLiteral(element, namesp);
2306                                 return;
2307                         }
2308
2309                         System.Type type = ob.GetType ();
2310                         if (type == typeof(System.Xml.Schema.XmlSchemaSimpleContentExtension))
2311                                 ;
2312                         else {
2313                                 throw CreateUnknownTypeException (ob);
2314                         }
2315
2316                         if (writeWrappingElem) {
2317                                 WriteStartElement (element, namesp, ob);
2318                         }
2319
2320                         if (needType) WriteXsiType("XmlSchemaSimpleContentExtension", "http://www.w3.org/2001/XMLSchema");
2321
2322                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2323
2324                         ICollection o108 = ob.@UnhandledAttributes;
2325                         if (o108 != null) {
2326                                 foreach (XmlAttribute o109 in o108)
2327                                         if (o109.NamespaceURI != xmlNamespace)
2328                                                 WriteXmlAttribute (o109, ob);
2329                         }
2330
2331                         WriteAttribute ("id", "", ob.@Id);
2332                         WriteAttribute ("base", "", FromXmlQualifiedName (ob.@BaseTypeName));
2333
2334                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2335                         if (ob.@Attributes != null) {
2336                                 for (int n110 = 0; n110 < ob.@Attributes.Count; n110++) {
2337                                         if (ob.@Attributes[n110] == null) { }
2338                                         else if (ob.@Attributes[n110].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) {
2339                                                 WriteObject_XmlSchemaAttributeGroupRef (((System.Xml.Schema.XmlSchemaAttributeGroupRef) ob.@Attributes[n110]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
2340                                         }
2341                                         else if (ob.@Attributes[n110].GetType() == typeof(System.Xml.Schema.XmlSchemaAttribute)) {
2342                                                 WriteObject_XmlSchemaAttribute (((System.Xml.Schema.XmlSchemaAttribute) ob.@Attributes[n110]), "attribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2343                                         }
2344                                         else throw CreateUnknownTypeException (ob.@Attributes[n110]);
2345                                 }
2346                         }
2347                         WriteObject_XmlSchemaAnyAttribute (ob.@AnyAttribute, "anyAttribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2348                         if (writeWrappingElem) WriteEndElement (ob);
2349                 }
2350
2351                 void WriteObject_XmlSchemaSimpleContentRestriction (System.Xml.Schema.XmlSchemaSimpleContentRestriction ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
2352                 {
2353                         if (ob == null)
2354                         {
2355                                 if (isNullable)
2356                                         WriteNullTagLiteral(element, namesp);
2357                                 return;
2358                         }
2359
2360                         System.Type type = ob.GetType ();
2361                         if (type == typeof(System.Xml.Schema.XmlSchemaSimpleContentRestriction))
2362                                 ;
2363                         else {
2364                                 throw CreateUnknownTypeException (ob);
2365                         }
2366
2367                         if (writeWrappingElem) {
2368                                 WriteStartElement (element, namesp, ob);
2369                         }
2370
2371                         if (needType) WriteXsiType("XmlSchemaSimpleContentRestriction", "http://www.w3.org/2001/XMLSchema");
2372
2373                         WriteNamespaceDeclarations ((XmlSerializerNamespaces) ob.@Namespaces);
2374
2375                         ICollection o111 = ob.@UnhandledAttributes;
2376                         if (o111 != null) {
2377                                 foreach (XmlAttribute o112 in o111)
2378                                         if (o112.NamespaceURI != xmlNamespace)
2379                                                 WriteXmlAttribute (o112, ob);
2380                         }
2381
2382                         WriteAttribute ("id", "", ob.@Id);
2383                         WriteAttribute ("base", "", FromXmlQualifiedName (ob.@BaseTypeName));
2384
2385                         WriteObject_XmlSchemaAnnotation (ob.@Annotation, "annotation", "http://www.w3.org/2001/XMLSchema", false, false, true);
2386                         WriteObject_XmlSchemaSimpleType (ob.@BaseType, "simpleType", "http://www.w3.org/2001/XMLSchema", false, false, true);
2387                         if (ob.@Facets != null) {
2388                                 for (int n113 = 0; n113 < ob.@Facets.Count; n113++) {
2389                                         if (ob.@Facets[n113] == null) { }
2390                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaEnumerationFacet)) {
2391                                                 WriteObject_XmlSchemaEnumerationFacet (((System.Xml.Schema.XmlSchemaEnumerationFacet) ob.@Facets[n113]), "enumeration", "http://www.w3.org/2001/XMLSchema", false, false, true);
2392                                         }
2393                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaMaxLengthFacet)) {
2394                                                 WriteObject_XmlSchemaMaxLengthFacet (((System.Xml.Schema.XmlSchemaMaxLengthFacet) ob.@Facets[n113]), "maxLength", "http://www.w3.org/2001/XMLSchema", false, false, true);
2395                                         }
2396                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaMinLengthFacet)) {
2397                                                 WriteObject_XmlSchemaMinLengthFacet (((System.Xml.Schema.XmlSchemaMinLengthFacet) ob.@Facets[n113]), "minLength", "http://www.w3.org/2001/XMLSchema", false, false, true);
2398                                         }
2399                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaLengthFacet)) {
2400                                                 WriteObject_XmlSchemaLengthFacet (((System.Xml.Schema.XmlSchemaLengthFacet) ob.@Facets[n113]), "length", "http://www.w3.org/2001/XMLSchema", false, false, true);
2401                                         }
2402                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaFractionDigitsFacet)) {
2403                                                 WriteObject_XmlSchemaFractionDigitsFacet (((System.Xml.Schema.XmlSchemaFractionDigitsFacet) ob.@Facets[n113]), "fractionDigits", "http://www.w3.org/2001/XMLSchema", false, false, true);
2404                                         }
2405                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaTotalDigitsFacet)) {
2406                                                 WriteObject_XmlSchemaTotalDigitsFacet (((System.Xml.Schema.XmlSchemaTotalDigitsFacet) ob.@Facets[n113]), "totalDigits", "http://www.w3.org/2001/XMLSchema", false, false, true);
2407                                         }
2408                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaMaxInclusiveFacet)) {
2409                                                 WriteObject_XmlSchemaMaxInclusiveFacet (((System.Xml.Schema.XmlSchemaMaxInclusiveFacet) ob.@Facets[n113]), "maxInclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
2410                                         }
2411                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaMaxExclusiveFacet)) {
2412                                                 WriteObject_XmlSchemaMaxExclusiveFacet (((System.Xml.Schema.XmlSchemaMaxExclusiveFacet) ob.@Facets[n113]), "maxExclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
2413                                         }
2414                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaMinInclusiveFacet)) {
2415                                                 WriteObject_XmlSchemaMinInclusiveFacet (((System.Xml.Schema.XmlSchemaMinInclusiveFacet) ob.@Facets[n113]), "minInclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
2416                                         }
2417                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaMinExclusiveFacet)) {
2418                                                 WriteObject_XmlSchemaMinExclusiveFacet (((System.Xml.Schema.XmlSchemaMinExclusiveFacet) ob.@Facets[n113]), "minExclusive", "http://www.w3.org/2001/XMLSchema", false, false, true);
2419                                         }
2420                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaWhiteSpaceFacet)) {
2421                                                 WriteObject_XmlSchemaWhiteSpaceFacet (((System.Xml.Schema.XmlSchemaWhiteSpaceFacet) ob.@Facets[n113]), "whiteSpace", "http://www.w3.org/2001/XMLSchema", false, false, true);
2422                                         }
2423                                         else if (ob.@Facets[n113].GetType() == typeof(System.Xml.Schema.XmlSchemaPatternFacet)) {
2424                                                 WriteObject_XmlSchemaPatternFacet (((System.Xml.Schema.XmlSchemaPatternFacet) ob.@Facets[n113]), "pattern", "http://www.w3.org/2001/XMLSchema", false, false, true);
2425                                         }
2426                                         else throw CreateUnknownTypeException (ob.@Facets[n113]);
2427                                 }
2428                         }
2429                         if (ob.@Attributes != null) {
2430                                 for (int n114 = 0; n114 < ob.@Attributes.Count; n114++) {
2431                                         if (ob.@Attributes[n114] == null) { }
2432                                         else if (ob.@Attributes[n114].GetType() == typeof(System.Xml.Schema.XmlSchemaAttributeGroupRef)) {
2433                                                 WriteObject_XmlSchemaAttributeGroupRef (((System.Xml.Schema.XmlSchemaAttributeGroupRef) ob.@Attributes[n114]), "attributeGroup", "http://www.w3.org/2001/XMLSchema", false, false, true);
2434                                         }
2435                                         else if (ob.@Attributes[n114].GetType() == typeof(System.Xml.Schema.XmlSchemaAttribute)) {
2436                                                 WriteObject_XmlSchemaAttribute (((System.Xml.Schema.XmlSchemaAttribute) ob.@Attributes[n114]), "attribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2437                                         }
2438                                         else throw CreateUnknownTypeException (ob.@Attributes[n114]);
2439                                 }
2440                         }
2441                         WriteObject_XmlSchemaAnyAttribute (ob.@AnyAttribute, "anyAttribute", "http://www.w3.org/2001/XMLSchema", false, false, true);
2442                         if (writeWrappingElem) WriteEndElement (ob);
2443                 }
2444
2445                 protected override void InitCallbacks ()
2446                 {
2447                 }
2448
2449         }
2450
2451 }
2452