Merge pull request #1196 from tritao/master
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSchemaExporterTests.cs
index be122eb1c08d34a7f98a6225a56141f4359223b5..fc55852869da82e5aaa0c3273a4f12edf38665a2 100644 (file)
@@ -24,6 +24,14 @@ namespace MonoTests.System.XmlSerialization
        [TestFixture]
        public class XmlSchemaExporterTests
        {
+               const string ANamespace = "some:urn";
+               const string AnotherNamespace = "another:urn";
+
+               string Infoset (string source)
+               {
+                       return XmlSerializerTests.Infoset (source);
+               }
+
                private XmlSchemas Export (Type type)
                {
                        return Export (type, string.Empty);
@@ -64,12 +72,12 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSTimeSpan\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
                                "  <xs:element name=\"TimeSpan\" type=\"tns:TimeSpan\" />{0}" +
                                "  <xs:complexType name=\"TimeSpan\" />{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (TimeSpan));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -77,16 +85,15 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
                                "  <xs:element name=\"TimeSpan\" type=\"TimeSpan\" />{0}" +
                                "  <xs:complexType name=\"TimeSpan\" />{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                public void ExportStruct_Array ()
                {
@@ -96,17 +103,17 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSTimeSpanArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpanArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfTimeSpan\" type=\"tns:ArrayOfTimeSpan\" />{0}" +
+                               "  <xs:element name=\"ArrayOfTimeSpan\" nillable=\"true\" type=\"tns:ArrayOfTimeSpan\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
                                "    <xs:sequence>{0}" +
-                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"tns:TimeSpan\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" type=\"tns:TimeSpan\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
                                "  <xs:complexType name=\"TimeSpan\" />{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (TimeSpan[]));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -114,21 +121,20 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfTimeSpan\" type=\"ArrayOfTimeSpan\" />{0}" +
+                               "  <xs:element name=\"ArrayOfTimeSpan\" nillable=\"true\" type=\"ArrayOfTimeSpan\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
                                "    <xs:sequence>{0}" +
-                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"TimeSpan\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" type=\"TimeSpan\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
                                "  <xs:complexType name=\"TimeSpan\" />{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_SimpleClass ()
                {
                        XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
@@ -145,16 +151,16 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSSimpleClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"SimpleClass\" type=\"tns:SimpleClass\" />{0}" +
+                               "  <xs:element name=\"SimpleClass\" nillable=\"true\" type=\"tns:SimpleClass\" />{0}" +
                                "  <xs:complexType name=\"SimpleClass\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (SimpleClass), overrides);
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -162,20 +168,19 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"SimpleClass\" type=\"SimpleClass\" />{0}" +
+                               "  <xs:element name=\"SimpleClass\" nillable=\"true\" type=\"SimpleClass\" />{0}" +
                                "  <xs:complexType name=\"SimpleClass\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_StringCollection ()
                {
                        XmlSchemas schemas = Export (typeof (StringCollection), "NSStringCollection");
@@ -184,16 +189,16 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSStringCollection\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollection\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfString\" type=\"tns:ArrayOfString\" />{0}" +
+                               "  <xs:element name=\"ArrayOfString\" nillable=\"true\" type=\"tns:ArrayOfString\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfString\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (StringCollection));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -201,20 +206,19 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfString\" type=\"ArrayOfString\" />{0}" +
+                               "  <xs:element name=\"ArrayOfString\" nillable=\"true\" type=\"ArrayOfString\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfString\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_StringCollectionContainer ()
                {
                        XmlSchemas schemas = Export (typeof (StringCollectionContainer), "NSStringCollectionContainer");
@@ -223,10 +227,10 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSStringCollectionContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollectionContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"StringCollectionContainer\" type=\"tns:StringCollectionContainer\" />{0}" +
+                               "  <xs:element name=\"StringCollectionContainer\" nillable=\"true\" type=\"tns:StringCollectionContainer\" />{0}" +
                                "  <xs:complexType name=\"StringCollectionContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Messages\" type=\"tns:ArrayOfString\" />{0}" +
@@ -237,7 +241,7 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (StringCollectionContainer));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -245,10 +249,10 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"StringCollectionContainer\" type=\"StringCollectionContainer\" />{0}" +
+                               "  <xs:element name=\"StringCollectionContainer\" nillable=\"true\" type=\"StringCollectionContainer\" />{0}" +
                                "  <xs:complexType name=\"StringCollectionContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Messages\" type=\"ArrayOfString\" />{0}" +
@@ -259,11 +263,10 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_ArrayContainer ()
                {
                        XmlSchemas schemas = Export (typeof (ArrayContainer), "NSArrayContainer");
@@ -272,10 +275,10 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayContainer\" type=\"tns:ArrayContainer\" />{0}" +
+                               "  <xs:element name=\"ArrayContainer\" nillable=\"true\" type=\"tns:ArrayContainer\" />{0}" +
                                "  <xs:complexType name=\"ArrayContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfAnyType\" />{0}" +
@@ -286,7 +289,7 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (ArrayContainer));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -294,10 +297,10 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayContainer\" type=\"ArrayContainer\" />{0}" +
+                               "  <xs:element name=\"ArrayContainer\" nillable=\"true\" type=\"ArrayContainer\" />{0}" +
                                "  <xs:complexType name=\"ArrayContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"ArrayOfAnyType\" />{0}" +
@@ -308,11 +311,10 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_ClassArrayContainer ()
                {
                        XmlSchemas schemas = Export (typeof (ClassArrayContainer), "NSClassArrayContainer");
@@ -321,10 +323,10 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSClassArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSClassArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ClassArrayContainer\" type=\"tns:ClassArrayContainer\" />{0}" +
+                               "  <xs:element name=\"ClassArrayContainer\" nillable=\"true\" type=\"tns:ClassArrayContainer\" />{0}" +
                                "  <xs:complexType name=\"ClassArrayContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
@@ -340,7 +342,7 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (ClassArrayContainer));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -348,10 +350,10 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ClassArrayContainer\" type=\"ClassArrayContainer\" />{0}" +
+                               "  <xs:element name=\"ClassArrayContainer\" nillable=\"true\" type=\"ClassArrayContainer\" />{0}" +
                                "  <xs:complexType name=\"ClassArrayContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"ArrayOfSimpleClass\" />{0}" +
@@ -367,11 +369,10 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_SimpleClassWithXmlAttributes ()
                {
                        XmlSchemas schemas = Export (typeof (SimpleClassWithXmlAttributes), "NSSimpleClassWithXmlAttributes");
@@ -380,14 +381,14 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSSimpleClassWithXmlAttributes\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassWithXmlAttributes\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"simple\" type=\"tns:SimpleClassWithXmlAttributes\" />{0}" +
+                               "  <xs:element name=\"simple\" nillable=\"true\" type=\"tns:SimpleClassWithXmlAttributes\" />{0}" +
                                "  <xs:complexType name=\"SimpleClassWithXmlAttributes\">{0}" +
                                "    <xs:attribute name=\"member\" type=\"xs:string\" />{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (SimpleClassWithXmlAttributes));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -395,19 +396,17 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"simple\" type=\"SimpleClassWithXmlAttributes\" />{0}" +
+                               "  <xs:element name=\"simple\" nillable=\"true\" type=\"SimpleClassWithXmlAttributes\" />{0}" +
                                "  <xs:complexType name=\"SimpleClassWithXmlAttributes\">{0}" +
                                "    <xs:attribute name=\"member\" type=\"xs:string\" />{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono does not translate default values to corresponding enum fields
-               [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                public void ExportClass_Field ()
                {
                        XmlSchemas schemas = Export (typeof (Field), "NSField");
@@ -416,15 +415,20 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSField\" elementFormDefault=\"qualified\" targetNamespace=\"NSField\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"field\" type=\"tns:Field\" />{0}" +
+                               "  <xs:element name=\"field\" nillable=\"true\" type=\"tns:Field\" />{0}" +
                                "  <xs:complexType name=\"Field\">{0}" +
+                               "    <xs:attribute default=\"one\" name=\"flag1\" type=\"tns:FlagEnum\" />{0}" +
+                               "    <xs:attribute default=\"one\" name=\"flag2\" type=\"tns:FlagEnum\" />{0}" +
+                               "    <xs:attribute default=\"one two\" form=\"qualified\" name=\"flag3\" type=\"tns:FlagEnum\" />{0}" +
+                               "    <xs:attribute name=\"flag4\" type=\"tns:FlagEnum\" use=\"required\" />{0}" +
                                "    <xs:attribute name=\"modifiers\" type=\"tns:MapModifiers\" use=\"required\" />{0}" +
                                "    <xs:attribute form=\"unqualified\" name=\"modifiers2\" type=\"tns:MapModifiers\" use=\"required\" />{0}" +
-                               "    <xs:attribute default=\"0\" name=\"modifiers3\" type=\"tns:MapModifiers\" />{0}" +
-                               "    <xs:attribute default=\"0\" form=\"unqualified\" name=\"modifiers4\" type=\"tns:MapModifiers\" />{0}" +
+                               "    <xs:attribute default=\"public\" name=\"modifiers3\" type=\"tns:MapModifiers\" />{0}" +
+                               "    <xs:attribute default=\"protected\" form=\"unqualified\" name=\"modifiers4\" type=\"tns:MapModifiers\" />{0}" +
+                               "    <xs:attribute default=\"public\" form=\"qualified\" name=\"modifiers5\" type=\"tns:MapModifiers\" />{0}" +
                                "    <xs:attribute name=\"names\">{0}" +
                                "      <xs:simpleType>{0}" +
                                "        <xs:list itemType=\"xs:string\" />{0}" +
@@ -432,6 +436,17 @@ namespace MonoTests.System.XmlSerialization
                                "    </xs:attribute>{0}" +
                                "    <xs:attribute name=\"street\" type=\"xs:string\" />{0}" +
                                "  </xs:complexType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"one\" />{0}" +
+                               "          <xs:enumeration value=\"two\" />{0}" +
+                               "          <xs:enumeration value=\"four\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
                                "  <xs:simpleType name=\"MapModifiers\">{0}" +
                                "    <xs:list>{0}" +
                                "      <xs:simpleType>{0}" +
@@ -442,7 +457,7 @@ namespace MonoTests.System.XmlSerialization
                                "      </xs:simpleType>{0}" +
                                "    </xs:list>{0}" +
                                "  </xs:simpleType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (Field));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -450,15 +465,20 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"field\" type=\"Field\" />{0}" +
+                               "  <xs:element name=\"field\" nillable=\"true\" type=\"Field\" />{0}" +
                                "  <xs:complexType name=\"Field\">{0}" +
+                               "    <xs:attribute default=\"one\" name=\"flag1\" type=\"FlagEnum\" />{0}" +
+                               "    <xs:attribute default=\"one\" name=\"flag2\" type=\"FlagEnum\" />{0}" +
+                               "    <xs:attribute default=\"one two\" form=\"qualified\" name=\"flag3\" type=\"FlagEnum\" />{0}" +
+                               "    <xs:attribute name=\"flag4\" type=\"FlagEnum\" use=\"required\" />{0}" +
                                "    <xs:attribute name=\"modifiers\" type=\"MapModifiers\" use=\"required\" />{0}" +
                                "    <xs:attribute form=\"unqualified\" name=\"modifiers2\" type=\"MapModifiers\" use=\"required\" />{0}" +
-                               "    <xs:attribute default=\"0\" name=\"modifiers3\" type=\"MapModifiers\" />{0}" +
-                               "    <xs:attribute default=\"0\" form=\"unqualified\" name=\"modifiers4\" type=\"MapModifiers\" />{0}" +
+                               "    <xs:attribute default=\"public\" name=\"modifiers3\" type=\"MapModifiers\" />{0}" +
+                               "    <xs:attribute default=\"protected\" form=\"unqualified\" name=\"modifiers4\" type=\"MapModifiers\" />{0}" +
+                               "    <xs:attribute default=\"public\" form=\"qualified\" name=\"modifiers5\" type=\"MapModifiers\" />{0}" +
                                "    <xs:attribute name=\"names\">{0}" +
                                "      <xs:simpleType>{0}" +
                                "        <xs:list itemType=\"xs:string\" />{0}" +
@@ -466,6 +486,17 @@ namespace MonoTests.System.XmlSerialization
                                "    </xs:attribute>{0}" +
                                "    <xs:attribute name=\"street\" type=\"xs:string\" />{0}" +
                                "  </xs:complexType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"one\" />{0}" +
+                               "          <xs:enumeration value=\"two\" />{0}" +
+                               "          <xs:enumeration value=\"four\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
                                "  <xs:simpleType name=\"MapModifiers\">{0}" +
                                "    <xs:list>{0}" +
                                "      <xs:simpleType>{0}" +
@@ -476,11 +507,10 @@ namespace MonoTests.System.XmlSerialization
                                "      </xs:simpleType>{0}" +
                                "    </xs:list>{0}" +
                                "  </xs:simpleType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_MyList ()
                {
                        XmlSchemas schemas = Export (typeof (MyList), "NSMyList");
@@ -489,16 +519,16 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSMyList\" elementFormDefault=\"qualified\" targetNamespace=\"NSMyList\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfAnyType\" type=\"tns:ArrayOfAnyType\" />{0}" +
+                               "  <xs:element name=\"ArrayOfAnyType\" nillable=\"true\" type=\"tns:ArrayOfAnyType\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (MyList));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -506,20 +536,19 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfAnyType\" type=\"ArrayOfAnyType\" />{0}" +
+                               "  <xs:element name=\"ArrayOfAnyType\" nillable=\"true\" type=\"ArrayOfAnyType\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_Container ()
                {
                        XmlSchemas schemas = Export (typeof (Container), "NSContainer");
@@ -528,10 +557,10 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"Container\" type=\"tns:Container\" />{0}" +
+                               "  <xs:element name=\"Container\" nillable=\"true\" type=\"tns:Container\" />{0}" +
                                "  <xs:complexType name=\"Container\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
@@ -542,7 +571,7 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (Container));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -550,10 +579,10 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"Container\" type=\"Container\" />{0}" +
+                               "  <xs:element name=\"Container\" nillable=\"true\" type=\"Container\" />{0}" +
                                "  <xs:complexType name=\"Container\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"ArrayOfAnyType\" />{0}" +
@@ -564,11 +593,10 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_Container2 ()
                {
                        XmlSchemas schemas = Export (typeof (Container2), "NSContainer2");
@@ -577,10 +605,10 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSContainer2\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer2\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"Container2\" type=\"tns:Container2\" />{0}" +
+                               "  <xs:element name=\"Container2\" nillable=\"true\" type=\"tns:Container2\" />{0}" +
                                "  <xs:complexType name=\"Container2\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
@@ -591,7 +619,7 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (Container2));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -599,10 +627,10 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"Container2\" type=\"Container2\" />{0}" +
+                               "  <xs:element name=\"Container2\" nillable=\"true\" type=\"Container2\" />{0}" +
                                "  <xs:complexType name=\"Container2\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"ArrayOfAnyType\" />{0}" +
@@ -613,7 +641,7 @@ namespace MonoTests.System.XmlSerialization
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
@@ -625,7 +653,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_CDataContainer ()
                {
                        XmlSchemas schemas = Export (typeof (CDataContainer), "NSCDataContainer");
@@ -634,10 +661,10 @@ namespace MonoTests.System.XmlSerialization
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSCDataContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSCDataContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"CDataContainer\" type=\"tns:CDataContainer\" />{0}" +
+                               "  <xs:element name=\"CDataContainer\" nillable=\"true\" type=\"tns:CDataContainer\" />{0}" +
                                "  <xs:complexType name=\"CDataContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"cdata\">{0}" +
@@ -649,7 +676,7 @@ namespace MonoTests.System.XmlSerialization
                                "      </xs:element>{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (CDataContainer));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -657,10 +684,10 @@ namespace MonoTests.System.XmlSerialization
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"CDataContainer\" type=\"CDataContainer\" />{0}" +
+                               "  <xs:element name=\"CDataContainer\" nillable=\"true\" type=\"CDataContainer\" />{0}" +
                                "  <xs:complexType name=\"CDataContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"cdata\">{0}" +
@@ -672,11 +699,10 @@ namespace MonoTests.System.XmlSerialization
                                "      </xs:element>{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_NodeContainer ()
                {
                        XmlSchemas schemas = Export (typeof (NodeContainer), "NSNodeContainer");
@@ -688,7 +714,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSNodeContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSNodeContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"NodeContainer\" type=\"tns:NodeContainer\" />{0}" +
+                               "  <xs:element name=\"NodeContainer\" nillable=\"true\" type=\"tns:NodeContainer\" />{0}" +
                                "  <xs:complexType name=\"NodeContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"node\">{0}" +
@@ -711,7 +737,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"NodeContainer\" type=\"NodeContainer\" />{0}" +
+                               "  <xs:element name=\"NodeContainer\" nillable=\"true\" type=\"NodeContainer\" />{0}" +
                                "  <xs:complexType name=\"NodeContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"node\">{0}" +
@@ -728,7 +754,7 @@ namespace MonoTests.System.XmlSerialization
 
                [Test]
                [Category ("NotWorking")] // Mono does not generate the <xs:choice> node
-               [Category ("NotDotNet")] // Mono bug ##77117 and MS.NET randomly modifies the order of the elements!
+               [Category ("NotDotNet")] // MS.NET randomly modifies the order of the elements! -> Of course. There is nothing strange. The test is rather strange.
                public void ExportClass_Choices ()
                {
                        XmlSchemas schemas = Export (typeof (Choices), "NSChoices");
@@ -775,11 +801,8 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
 #if ONLY_1_1
                [Category ("NotDotNet")] // MS.NET 1.x does not escape spaces in a type name, bug is fixed in .NET 2.0
-#else
-               [Category ("NotDotNet")] // Mono bug ##77117
 #endif
                public void ExportClass_TestSpace ()
                {
@@ -792,7 +815,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSTestSpace\" elementFormDefault=\"qualified\" targetNamespace=\"NSTestSpace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"Type_x0020_with_x0020_space\" type=\"tns:Type_x0020_with_x0020_space\" />{0}" +
+                               "  <xs:element name=\"Type_x0020_with_x0020_space\" nillable=\"true\" type=\"tns:Type_x0020_with_x0020_space\" />{0}" +
                                "  <xs:complexType name=\"Type_x0020_with_x0020_space\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Element_x0020_with_x0020_space\" type=\"xs:int\" />{0}" +
@@ -810,7 +833,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"Type_x0020_with_x0020_space\" type=\"Type_x0020_with_x0020_space\" />{0}" +
+                               "  <xs:element name=\"Type_x0020_with_x0020_space\" nillable=\"true\" type=\"Type_x0020_with_x0020_space\" />{0}" +
                                "  <xs:complexType name=\"Type_x0020_with_x0020_space\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Element_x0020_with_x0020_space\" type=\"xs:int\" />{0}" +
@@ -821,7 +844,107 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
+               public void ExportClass_OptionalValueTypeContainer ()
+               {
+                       XmlAttributeOverrides overrides;
+                       XmlAttributes attr;
+
+                       XmlSchemas schemas = Export (typeof (OptionalValueTypeContainer));
+                       Assert.AreEqual (2, schemas.Count, "#1");
+
+                       StringWriter sw = new StringWriter ();
+                       schemas[0].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:import namespace=\"{2}\" />{0}" +
+                               "  <xs:element name=\"optionalValue\" xmlns:q1=\"{2}\" type=\"q1:optionalValueType\" />{0}" +
+                               "</xs:schema>", Environment.NewLine, AnotherNamespace, ANamespace),
+                               sw.ToString (), "#2");
+
+                       sw.GetStringBuilder ().Length = 0;
+                       schemas[1].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:complexType name=\"optionalValueType\">{0}" +
+                               "    <xs:sequence>{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"one four\" name=\"Attributes\" type=\"tns:FlagEnum\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"one\" name=\"Flags\" type=\"tns:FlagEnum\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"false\" name=\"IsEmpty\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"false\" name=\"IsNull\" type=\"xs:boolean\" />{0}" +
+                               "    </xs:sequence>{0}" +
+                               "  </xs:complexType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"one\" />{0}" +
+                               "          <xs:enumeration value=\"two\" />{0}" +
+                               "          <xs:enumeration value=\"four\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "</xs:schema>", Environment.NewLine, ANamespace), sw.ToString (), "#3");
+
+                       overrides = new XmlAttributeOverrides ();
+                       attr = new XmlAttributes ();
+
+                       // remove the DefaultValue attribute on the Flags member
+                       overrides.Add (typeof (OptionalValueTypeContainer), "Flags", attr);
+                       // remove the DefaultValue attribute on the Attributes member
+                       overrides.Add (typeof (OptionalValueTypeContainer), "Attributes", attr);
+                       // remove the DefaultValue attribute on the IsEmpty member
+                       overrides.Add (typeof (OptionalValueTypeContainer), "IsEmpty", attr);
+                       // remove the DefaultValue attribute on the IsNull member
+                       overrides.Add (typeof (OptionalValueTypeContainer), "IsNull", attr);
+
+                       schemas = Export (typeof (OptionalValueTypeContainer), overrides, "urn:myNS");
+                       Assert.AreEqual (2, schemas.Count, "#4");
+
+                       sw.GetStringBuilder ().Length = 0;
+                       schemas[0].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:import namespace=\"{2}\" />{0}" +
+                               "  <xs:element name=\"optionalValue\" xmlns:q1=\"{2}\" type=\"q1:optionalValueType\" />{0}" +
+                               "</xs:schema>", Environment.NewLine, AnotherNamespace, ANamespace),
+                               sw.ToString (), "#5");
+
+                       sw.GetStringBuilder ().Length = 0;
+                       schemas[1].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:complexType name=\"optionalValueType\">{0}" +
+                               "    <xs:sequence>{0}" +
+                               "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Attributes\" type=\"tns:FlagEnum\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Flags\" type=\"tns:FlagEnum\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"IsEmpty\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"IsNull\" type=\"xs:boolean\" />{0}" +
+                               "    </xs:sequence>{0}" +
+                               "  </xs:complexType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"one\" />{0}" +
+                               "          <xs:enumeration value=\"two\" />{0}" +
+                               "          <xs:enumeration value=\"four\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "</xs:schema>", Environment.NewLine, ANamespace), sw.ToString (), "#6");
+               }
+
+               [Test]
                public void ExportClass_ReadOnlyProperties ()
                {
                        XmlSchemas schemas = Export (typeof (ReadOnlyProperties), "NSReadOnlyProperties");
@@ -833,7 +956,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSReadOnlyProperties\" elementFormDefault=\"qualified\" targetNamespace=\"NSReadOnlyProperties\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ReadOnlyProperties\" type=\"tns:ReadOnlyProperties\" />{0}" +
+                               "  <xs:element name=\"ReadOnlyProperties\" nillable=\"true\" type=\"tns:ReadOnlyProperties\" />{0}" +
                                "  <xs:complexType name=\"ReadOnlyProperties\" />{0}" +
                                "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
 
@@ -846,13 +969,12 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ReadOnlyProperties\" type=\"ReadOnlyProperties\" />{0}" +
+                               "  <xs:element name=\"ReadOnlyProperties\" nillable=\"true\" type=\"ReadOnlyProperties\" />{0}" +
                                "  <xs:complexType name=\"ReadOnlyProperties\" />{0}" +
                                "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                public void ExportClass_ListDefaults ()
                {
@@ -865,7 +987,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSListDefaults\" elementFormDefault=\"qualified\" targetNamespace=\"NSListDefaults\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"root\" type=\"tns:ListDefaults\" />{0}" +
+                               "  <xs:element name=\"root\" nillable=\"true\" type=\"tns:ListDefaults\" />{0}" +
                                "  <xs:complexType name=\"ListDefaults\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list2\" type=\"tns:ArrayOfAnyType\" />{0}" +
@@ -902,7 +1024,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"root\" type=\"ListDefaults\" />{0}" +
+                               "  <xs:element name=\"root\" nillable=\"true\" type=\"ListDefaults\" />{0}" +
                                "  <xs:complexType name=\"ListDefaults\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list2\" type=\"ArrayOfAnyType\" />{0}" +
@@ -932,7 +1054,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_ClsPerson ()
                {
                        XmlSchemas schemas = Export (typeof (clsPerson), "NSClsPerson");
@@ -944,7 +1065,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSClsPerson\" elementFormDefault=\"qualified\" targetNamespace=\"NSClsPerson\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"clsPerson\" type=\"tns:clsPerson\" />{0}" +
+                               "  <xs:element name=\"clsPerson\" nillable=\"true\" type=\"tns:clsPerson\" />{0}" +
                                "  <xs:complexType name=\"clsPerson\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"EmailAccounts\" type=\"tns:ArrayOfAnyType\" />{0}" +
@@ -966,7 +1087,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"clsPerson\" type=\"clsPerson\" />{0}" +
+                               "  <xs:element name=\"clsPerson\" nillable=\"true\" type=\"clsPerson\" />{0}" +
                                "  <xs:complexType name=\"clsPerson\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"EmailAccounts\" type=\"ArrayOfAnyType\" />{0}" +
@@ -981,7 +1102,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_ArrayClass ()
                {
                        XmlSchemas schemas = Export (typeof (ArrayClass), "NSArrayClass");
@@ -993,13 +1113,13 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSArrayClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayClass\" type=\"tns:ArrayClass\" />{0}" +
+                               "  <xs:element name=\"ArrayClass\" nillable=\"true\" type=\"tns:ArrayClass\" />{0}" +
                                "  <xs:complexType name=\"ArrayClass\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"names\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
 
                        schemas = Export (typeof (ArrayClass));
                        Assert.AreEqual (1, schemas.Count, "#3");
@@ -1010,7 +1130,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayClass\" type=\"ArrayClass\" />{0}" +
+                               "  <xs:element name=\"ArrayClass\" nillable=\"true\" type=\"ArrayClass\" />{0}" +
                                "  <xs:complexType name=\"ArrayClass\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"names\" />{0}" +
@@ -1020,7 +1140,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                public void ExportClass_StructContainer ()
                {
@@ -1033,7 +1152,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSStructContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStructContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"StructContainer\" type=\"tns:StructContainer\" />{0}" +
+                               "  <xs:element name=\"StructContainer\" nillable=\"true\" type=\"tns:StructContainer\" />{0}" +
                                "  <xs:complexType name=\"StructContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Value\" type=\"tns:EnumDefaultValue\" />{0}" +
@@ -1053,7 +1172,7 @@ namespace MonoTests.System.XmlSerialization
                                "  </xs:simpleType>{0}" +
                                "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
                                "    <xs:sequence>{0}" +
-                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"tns:TimeSpan\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" type=\"tns:TimeSpan\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
                                "  <xs:complexType name=\"TimeSpan\" />{0}" +
@@ -1068,7 +1187,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"StructContainer\" type=\"StructContainer\" />{0}" +
+                               "  <xs:element name=\"StructContainer\" nillable=\"true\" type=\"StructContainer\" />{0}" +
                                "  <xs:complexType name=\"StructContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Value\" type=\"EnumDefaultValue\" />{0}" +
@@ -1088,13 +1207,172 @@ namespace MonoTests.System.XmlSerialization
                                "  </xs:simpleType>{0}" +
                                "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
                                "    <xs:sequence>{0}" +
-                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"TimeSpan\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" type=\"TimeSpan\" />{0}" +
                                "    </xs:sequence>{0}" +
                                "  </xs:complexType>{0}" +
                                "  <xs:complexType name=\"TimeSpan\" />{0}" +
                                "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
                }
 
+               [Test]
+               public void ExportClass_TestDefault ()
+               {
+                       XmlSchemas schemas = Export (typeof (TestDefault));
+                       Assert.AreEqual (1, schemas.Count, "#1");
+
+                       StringWriter sw = new StringWriter ();
+                       schemas [0].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"urn:myNS\" elementFormDefault=\"qualified\" targetNamespace=\"urn:myNS\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:element name=\"testDefault\" type=\"tns:TestDefault\" />{0}" +
+                               "  <xs:complexType name=\"TestDefault\">{0}" +
+                               "    <xs:sequence>{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"str\" type=\"xs:string\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"Default Value\" name=\"strDefault\" type=\"xs:string\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"true\" name=\"boolT\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"false\" name=\"boolF\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"10\" name=\"decimalval\" type=\"xs:decimal\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"one four\" name=\"flag\" type=\"tns:FlagEnum\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"e1 e4\" name=\"flagencoded\" type=\"tns:FlagEnum_Encoded\" />{0}" +
+                               "    </xs:sequence>{0}" +
+                               "  </xs:complexType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"one\" />{0}" +
+                               "          <xs:enumeration value=\"two\" />{0}" +
+                               "          <xs:enumeration value=\"four\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum_Encoded\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"e1\" />{0}" +
+                               "          <xs:enumeration value=\"e2\" />{0}" +
+                               "          <xs:enumeration value=\"e4\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+
+                       schemas = Export (typeof (TestDefault), "NSTestDefault");
+                       Assert.AreEqual (1, schemas.Count, "#3");
+
+                       sw.GetStringBuilder ().Length = 0;
+                       schemas [0].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"urn:myNS\" elementFormDefault=\"qualified\" targetNamespace=\"urn:myNS\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:element name=\"testDefault\" type=\"tns:TestDefault\" />{0}" +
+                               "  <xs:complexType name=\"TestDefault\">{0}" +
+                               "    <xs:sequence>{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"str\" type=\"xs:string\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"Default Value\" name=\"strDefault\" type=\"xs:string\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"true\" name=\"boolT\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"false\" name=\"boolF\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"10\" name=\"decimalval\" type=\"xs:decimal\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"one four\" name=\"flag\" type=\"tns:FlagEnum\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"e1 e4\" name=\"flagencoded\" type=\"tns:FlagEnum_Encoded\" />{0}" +
+                               "    </xs:sequence>{0}" +
+                               "  </xs:complexType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"one\" />{0}" +
+                               "          <xs:enumeration value=\"two\" />{0}" +
+                               "          <xs:enumeration value=\"four\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum_Encoded\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"e1\" />{0}" +
+                               "          <xs:enumeration value=\"e2\" />{0}" +
+                               "          <xs:enumeration value=\"e4\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+               }
+
+               [Test]
+               public void ExportClass_TestDefault_Overrides ()
+               {
+                       XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
+                       XmlAttributes attr = new XmlAttributes ();
+                       XmlTypeAttribute xmlType = new XmlTypeAttribute ("flagenum");
+                       xmlType.Namespace = "yetanother:urn";
+                       attr.XmlType = xmlType;
+                       overrides.Add (typeof (FlagEnum_Encoded), attr);
+
+                       XmlSchemas schemas = Export (typeof (TestDefault), overrides, "NSTestDefault");
+                       Assert.AreEqual (2, schemas.Count, "#1");
+
+                       StringWriter sw = new StringWriter ();
+                       schemas [0].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"urn:myNS\" elementFormDefault=\"qualified\" targetNamespace=\"urn:myNS\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:import namespace=\"yetanother:urn\" />{0}" +
+                               "  <xs:element name=\"testDefault\" type=\"tns:TestDefault\" />{0}" +
+                               "  <xs:complexType name=\"TestDefault\">{0}" +
+                               "    <xs:sequence>{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"str\" type=\"xs:string\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"Default Value\" name=\"strDefault\" type=\"xs:string\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"true\" name=\"boolT\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"false\" name=\"boolF\" type=\"xs:boolean\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"10\" name=\"decimalval\" type=\"xs:decimal\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"one four\" name=\"flag\" type=\"tns:FlagEnum\" />{0}" +
+                               "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" default=\"e1 e4\" name=\"flagencoded\" xmlns:q1=\"yetanother:urn\" type=\"q1:flagenum\" />{0}" +
+                               "    </xs:sequence>{0}" +
+                               "  </xs:complexType>{0}" +
+                               "  <xs:simpleType name=\"FlagEnum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"one\" />{0}" +
+                               "          <xs:enumeration value=\"two\" />{0}" +
+                               "          <xs:enumeration value=\"four\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+
+                       sw.GetStringBuilder ().Length = 0;
+                       schemas [1].Write (sw);
+
+                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                               "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
+                               "<xs:schema xmlns:tns=\"yetanother:urn\" elementFormDefault=\"qualified\" targetNamespace=\"yetanother:urn\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
+                               "  <xs:simpleType name=\"flagenum\">{0}" +
+                               "    <xs:list>{0}" +
+                               "      <xs:simpleType>{0}" +
+                               "        <xs:restriction base=\"xs:string\">{0}" +
+                               "          <xs:enumeration value=\"e1\" />{0}" +
+                               "          <xs:enumeration value=\"e2\" />{0}" +
+                               "          <xs:enumeration value=\"e4\" />{0}" +
+                               "        </xs:restriction>{0}" +
+                               "      </xs:simpleType>{0}" +
+                               "    </xs:list>{0}" +
+                               "  </xs:simpleType>{0}" +
+                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#3");
+               }
+
                [Test]
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
@@ -1104,7 +1382,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportClass_Array ()
                {
                        XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
@@ -1124,7 +1401,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfSimpleClass\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
+                               "  <xs:element name=\"ArrayOfSimpleClass\" nillable=\"true\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"tns:SimpleClass\" />{0}" +
@@ -1146,7 +1423,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfSimpleClass\" type=\"ArrayOfSimpleClass\" />{0}" +
+                               "  <xs:element name=\"ArrayOfSimpleClass\" nillable=\"true\" type=\"ArrayOfSimpleClass\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"SimpleClass\" />{0}" +
@@ -1250,7 +1527,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                public void ExportXmlSerializable ()
                {
@@ -1264,7 +1540,7 @@ namespace MonoTests.System.XmlSerialization
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSEmployee\" elementFormDefault=\"qualified\" targetNamespace=\"NSEmployee\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
                                "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
-                               "  <xs:element name=\"Employee\">{0}" +
+                               "  <xs:element name=\"Employee\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:element ref=\"xs:schema\" />{0}" +
@@ -1284,7 +1560,7 @@ namespace MonoTests.System.XmlSerialization
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
                                "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
-                               "  <xs:element name=\"Employee\">{0}" +
+                               "  <xs:element name=\"Employee\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:element ref=\"xs:schema\" />{0}" +
@@ -1296,7 +1572,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                public void ExportXmlSerializable_Schema ()
                {
@@ -1312,7 +1587,7 @@ namespace MonoTests.System.XmlSerialization
 #if ONLY_1_1
                                "  <xs:import namespace=\"urn:types-devx-com\" />{0}" +
 #endif
-                               "  <xs:element name=\"EmployeeSchema\">{0}" +
+                               "  <xs:element name=\"EmployeeSchema\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:any namespace=\"urn:types-devx-com\" />{0}" +
@@ -1347,7 +1622,7 @@ namespace MonoTests.System.XmlSerialization
 #if ONLY_1_1
                                "  <xs:import namespace=\"urn:types-devx-com\" />{0}" +
 #endif
-                               "  <xs:element name=\"EmployeeSchema\">{0}" +
+                               "  <xs:element name=\"EmployeeSchema\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:any namespace=\"urn:types-devx-com\" />{0}" +
@@ -1379,7 +1654,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSPrimitiveSchema\" elementFormDefault=\"qualified\" targetNamespace=\"NSPrimitiveSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"PrimitiveSchema\">{0}" +
+                               "  <xs:element name=\"PrimitiveSchema\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:any namespace=\"\" />{0}" +
@@ -1424,20 +1699,18 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
+#if !NET_2_0
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
-#if NET_2_0
-               [Category ("NotWorking")] // support for XmlSchemaProvider is not implemented
 #endif
                public void ExportXmlSerializable_SchemaProvider ()
                {
                        XmlSchemas schemas = Export (typeof (EmployeeSchemaProvider), "NSEmployeeSchemaProvider");
-                       Assert.AreEqual (1, schemas.Count, "#1");
+                       //Assert.AreEqual (1, schemas.Count, "#1"); //# of returned schemas is checked in ExportXmlSerializable_SchemaProvider1
 
                        StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSEmployeeSchemaProvider\" elementFormDefault=\"qualified\" targetNamespace=\"NSEmployeeSchemaProvider\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
 #if NET_2_0
@@ -1445,7 +1718,7 @@ namespace MonoTests.System.XmlSerialization
                                "  <xs:element name=\"employeeRoot\" nillable=\"true\" xmlns:q1=\"urn:types-devx-com\" type=\"q1:employeeRoot\" />{0}" +
 #else
                                "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
-                               "  <xs:element name=\"EmployeeSchemaProvider\">{0}" +
+                               "  <xs:element name=\"EmployeeSchemaProvider\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:element ref=\"xs:schema\" />{0}" +
@@ -1454,15 +1727,15 @@ namespace MonoTests.System.XmlSerialization
                                "    </xs:complexType>{0}" +
                                "  </xs:element>{0}" +
 #endif
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#2");
 
                        schemas = Export (typeof (EmployeeSchemaProvider));
-                       Assert.AreEqual (1, schemas.Count, "#3");
+                       //Assert.AreEqual (1, schemas.Count, "#3");
 
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
 #if NET_2_0
@@ -1470,7 +1743,7 @@ namespace MonoTests.System.XmlSerialization
                                "  <xs:element name=\"employeeRoot\" nillable=\"true\" xmlns:q1=\"urn:types-devx-com\" type=\"q1:employeeRoot\" />{0}" +
 #else
                                "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
-                               "  <xs:element name=\"EmployeeSchemaProvider\">{0}" +
+                               "  <xs:element name=\"EmployeeSchemaProvider\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:element ref=\"xs:schema\" />{0}" +
@@ -1479,23 +1752,23 @@ namespace MonoTests.System.XmlSerialization
                                "    </xs:complexType>{0}" +
                                "  </xs:element>{0}" +
 #endif
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ()), "#4");
 
                        schemas = Export (typeof (PrimitiveSchemaProvider), "NSPrimitiveSchemaProvider");
-                       Assert.AreEqual (1, schemas.Count, "#5");
+                       //Assert.AreEqual (1, schemas.Count, "#5");
 
                        sw.GetStringBuilder ().Length = 0;
                        schemas[0].Write (sw);
 
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSPrimitiveSchemaProvider\" elementFormDefault=\"qualified\" targetNamespace=\"NSPrimitiveSchemaProvider\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
 #if NET_2_0
-                               "  <xs:import />{0}" +
+                               //"  <xs:import />{0}" +
                                "  <xs:element name=\"int\" nillable=\"true\" type=\"xs:int\" />{0}" +
 #else
                                "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
-                               "  <xs:element name=\"PrimitiveSchemaProvider\">{0}" +
+                               "  <xs:element name=\"PrimitiveSchemaProvider\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:element ref=\"xs:schema\" />{0}" +
@@ -1504,12 +1777,18 @@ namespace MonoTests.System.XmlSerialization
                                "    </xs:complexType>{0}" +
                                "  </xs:element>{0}" +
 #endif
-                               "</xs:schema>", Environment.NewLine), sw.ToString (), "#6");
+                               "</xs:schema>", Environment.NewLine)), Infoset (sw.ToString ().Replace("<xs:import />" + Environment.NewLine, "")), "#6");
+               }
 
-                       schemas = Export (typeof (PrimitiveSchemaProvider));
-                       Assert.AreEqual (1, schemas.Count, "#7");
+               [Test]
+#if NET_2_0
+               [Category ("NotWorking")] // support for XmlSchemaProvider is not implemented
+#endif
+               public void ExportXmlSerializable_SchemaProvider1 () {
+                       XmlSchemas schemas = Export (typeof (PrimitiveSchemaProvider));
+                       Assert.AreEqual (1, schemas.Count, "#1");
 
-                       sw.GetStringBuilder ().Length = 0;
+                       StringWriter sw = new StringWriter ();
                        schemas[0].Write (sw);
 
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
@@ -1519,7 +1798,7 @@ namespace MonoTests.System.XmlSerialization
                                "  <xs:element name=\"int\" nillable=\"true\" type=\"xs:int\" />{0}" +
 #else
                                "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
-                               "  <xs:element name=\"PrimitiveSchemaProvider\">{0}" +
+                               "  <xs:element name=\"PrimitiveSchemaProvider\" nillable=\"true\">{0}" +
                                "    <xs:complexType>{0}" +
                                "      <xs:sequence>{0}" +
                                "        <xs:element ref=\"xs:schema\" />{0}" +
@@ -1532,7 +1811,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
 #if NET_2_0
                [Category ("NotWorking")] // support for XmlSchemaProvider is not implemented
@@ -1553,7 +1831,7 @@ namespace MonoTests.System.XmlSerialization
 #if NET_2_0
                                "  <xs:import />{0}" +
 #endif
-                               "  <xs:element name=\"XmlSerializableContainer\" type=\"tns:XmlSerializableContainer\" />{0}" +
+                               "  <xs:element name=\"XmlSerializableContainer\" nillable=\"true\" type=\"tns:XmlSerializableContainer\" />{0}" +
                                "  <xs:complexType name=\"XmlSerializableContainer\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Slave\">{0}" +
@@ -1747,7 +2025,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportXsdPrimitive ()
                {
                        ArrayList types = new ArrayList ();
@@ -1782,7 +2059,8 @@ namespace MonoTests.System.XmlSerialization
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                        "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
                                        "  <xs:element name=\"{2}\" {3}type=\"xs:{2}\" />{0}" +
-                                       "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.XmlType, ""),
+                                       "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.XmlType, 
+                                       typeDesc.IsNillable ? "nillable=\"true\" " : ""),
                                        sw.ToString (), typeDesc.Type.FullName + "#2");
 
                                schemas = Export (typeDesc.Type);
@@ -1795,13 +2073,13 @@ namespace MonoTests.System.XmlSerialization
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                        "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
                                        "  <xs:element name=\"{1}\" {2}type=\"xs:{1}\" />{0}" +
-                                       "</xs:schema>", Environment.NewLine, typeDesc.XmlType, ""),
+                                       "</xs:schema>", Environment.NewLine, typeDesc.XmlType, 
+                                       typeDesc.IsNillable ? "nillable=\"true\" " : ""),
                                        sw.ToString (), typeDesc.Type.FullName + "#4");
                        }
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
                public void ExportXsdPrimitive_Object ()
                {
@@ -1814,7 +2092,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSAnyType\" elementFormDefault=\"qualified\" targetNamespace=\"NSAnyType\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"anyType\" />{0}" +
+                               "  <xs:element name=\"anyType\" nillable=\"true\" />{0}" +
                                "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
 
                        schemas = Export (typeof (object));
@@ -1826,12 +2104,11 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"anyType\" />{0}" +
+                               "  <xs:element name=\"anyType\" nillable=\"true\" />{0}" +
                                "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportXsdPrimitive_ByteArray ()
                {
                        XmlSchemas schemas = Export (typeof (byte[]), "NSByteArray");
@@ -1843,7 +2120,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSByteArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSByteArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"base64Binary\" type=\"xs:base64Binary\" />{0}" +
+                               "  <xs:element name=\"base64Binary\" nillable=\"true\" type=\"xs:base64Binary\" />{0}" +
                                "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
 
                        schemas = Export (typeof (byte[]));
@@ -1855,36 +2132,32 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"base64Binary\" type=\"xs:base64Binary\" />{0}" +
+                               "  <xs:element name=\"base64Binary\" nillable=\"true\" type=\"xs:base64Binary\" />{0}" +
                                "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
                }
 
                [Test]
-#if NET_2_0
-               [Category ("NotWorking")] // in 2.0 profile, QName must be nillable
-#endif
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportXsdPrimitive_Arrays ()
                {
                        ArrayList types = new ArrayList ();
-                       types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte"));
-                       types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean"));
-                       types.Add (new TypeDescription (typeof (short[]), true, "short", "Short"));
-                       types.Add (new TypeDescription (typeof (int[]), true, "int", "Int"));
-                       types.Add (new TypeDescription (typeof (long[]), true, "long", "Long"));
-                       types.Add (new TypeDescription (typeof (float[]), true, "float", "Float"));
-                       types.Add (new TypeDescription (typeof (double[]), true, "double", "Double"));
-                       types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal"));
-                       types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort"));
-                       types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt"));
-                       types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong"));
-                       types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime"));
+                       types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte", true));
+                       types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean", true));
+                       types.Add (new TypeDescription (typeof (short[]), true, "short", "Short", true));
+                       types.Add (new TypeDescription (typeof (int[]), true, "int", "Int", true));
+                       types.Add (new TypeDescription (typeof (long[]), true, "long", "Long", true));
+                       types.Add (new TypeDescription (typeof (float[]), true, "float", "Float", true));
+                       types.Add (new TypeDescription (typeof (double[]), true, "double", "Double", true));
+                       types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal", true));
+                       types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort", true));
+                       types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt", true));
+                       types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong", true));
+                       types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime", true));
 #if NET_2_0
-                       types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
+                       types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true, true));
 #else
-                       types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName"));
+                       types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
 #endif
-                       types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true));
+                       types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true, true));
 
                        foreach (TypeDescription typeDesc in types) {
                                XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
@@ -1896,15 +2169,16 @@ namespace MonoTests.System.XmlSerialization
                                Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                        "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                                       "  <xs:element name=\"ArrayOf{2}\" type=\"tns:ArrayOf{2}\" />{0}" +
+                                       "  <xs:element name=\"ArrayOf{2}\" {5}type=\"tns:ArrayOf{2}\" />{0}" +
                                        "  <xs:complexType name=\"ArrayOf{2}\">{0}" +
                                        "    <xs:sequence>{0}" +
-                                       "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"{3}\" {5}type=\"{4}:{3}\" />{0}" +
+                                       "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"{3}\" {6}type=\"{4}:{3}\" />{0}" +
                                        "    </xs:sequence>{0}" +
                                        "  </xs:complexType>{0}" +
                                        "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.ArrayType, typeDesc.XmlType, 
-                                       typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
-                                       sw.ToString (), typeDesc.Type.FullName + "#2");
+                                       typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : "",
+                                       typeDesc.IsElementNillable ? "nillable=\"true\" " : ""),
+                                       sw.ToString (), typeDesc.Type.FullName + "#2" + "|" + typeDesc.IsNillable);
 
                                schemas = Export (typeDesc.Type);
                                Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#3");
@@ -1915,20 +2189,20 @@ namespace MonoTests.System.XmlSerialization
                                Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                        "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                                       "  <xs:element name=\"ArrayOf{1}\" type=\"ArrayOf{1}\" />{0}" +
+                                       "  <xs:element name=\"ArrayOf{1}\" {4}type=\"ArrayOf{1}\" />{0}" +
                                        "  <xs:complexType name=\"ArrayOf{1}\">{0}" +
                                        "    <xs:sequence>{0}" +
-                                       "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"{2}\" {4}type=\"{3}:{2}\" />{0}" +
+                                       "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"{2}\" {5}type=\"{3}:{2}\" />{0}" +
                                        "    </xs:sequence>{0}" +
                                        "  </xs:complexType>{0}" +
                                        "</xs:schema>", Environment.NewLine, typeDesc.ArrayType, typeDesc.XmlType,
-                                       typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
+                                       typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : "",
+                                       typeDesc.IsElementNillable ? "nillable=\"true\" " : ""),
                                        sw.ToString (), typeDesc.Type.FullName + "#4");
                        }
                }
 
                [Test]
-               [Category ("NotDotNet")] // Mono bug ##77117
                public void ExportXsdPrimitive_Object_Arrays ()
                {
                        XmlSchemas schemas = Export (typeof (object[]), "NSArrayOfAnyType");
@@ -1940,7 +2214,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema xmlns:tns=\"NSArrayOfAnyType\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayOfAnyType\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfAnyType\" type=\"tns:ArrayOfAnyType\" />{0}" +
+                               "  <xs:element name=\"ArrayOfAnyType\" nillable=\"true\" type=\"tns:ArrayOfAnyType\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
@@ -1957,7 +2231,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
                                "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
-                               "  <xs:element name=\"ArrayOfAnyType\" type=\"ArrayOfAnyType\" />{0}" +
+                               "  <xs:element name=\"ArrayOfAnyType\" nillable=\"true\" type=\"ArrayOfAnyType\" />{0}" +
                                "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
                                "    <xs:sequence>{0}" +
                                "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
@@ -2303,13 +2577,19 @@ namespace MonoTests.System.XmlSerialization
                        {
                        }
 
-                       public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable)
+                       public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable) :
+                               this (type, xsdType, xmlType, arrayType, isNillable, false)
+                       {
+                       }
+
+                       public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable, bool isElementNillable)
                        {
                                _type = type;
                                _xsdType = xsdType;
                                _xmlType = xmlType;
                                _arrayType = arrayType;
                                _isNillable = isNillable;
+                               _isElementNillable = isElementNillable;
                        }
 
                        public Type Type {
@@ -2332,11 +2612,16 @@ namespace MonoTests.System.XmlSerialization
                                get { return _isNillable; }
                        }
 
+                       public bool IsElementNillable {
+                               get { return _isElementNillable; }
+                       }
+
                        private Type _type;
                        private bool _xsdType;
                        private string _xmlType;
                        private string _arrayType;
                        private bool _isNillable;
+                       private bool _isElementNillable;
                }
 
                public class StructContainer