System.Xml.Tests.TC_SchemaSet_Misc.Dev10_40495 C# (CSharp) Method

Dev10_40495() private method

private Dev10_40495 ( ) : void
return void
        public void Dev10_40495()
        {
            Initialize();
            const string schema1Str = @"<xs:schema xmlns:tns=""http://BizTalk_Server_Project2.Schema1"" xmlns:b=""http://schemas.microsoft.com/BizTalk/2003"" attributeFormDefault=""unqualified"" elementFormDefault=""qualified"" targetNamespace=""http://BizTalk_Server_Project2.Schema1"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:include schemaLocation=""S3"" />
  <xs:include schemaLocation=""S2"" />
  <xs:element name=""Root"">
    <xs:complexType>
      <xs:sequence>
        <xs:element name=""FxTypeElement"">
          <xs:complexType>
            <xs:complexContent mixed=""false"">
              <xs:extension base=""tns:FxType"">
                <xs:attribute name=""Field"" type=""xs:string"" />
              </xs:extension>
            </xs:complexContent>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>";

            const string schema2Str = @"<xs:schema xmlns:b=""http://schemas.microsoft.com/BizTalk/2003"" attributeFormDefault=""unqualified"" elementFormDefault=""qualified"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:complexType name=""FxType"">
    <xs:attribute name=""Fx2"" type=""xs:string"" />
  </xs:complexType>
</xs:schema>";

            const string schema3Str = @"<xs:schema xmlns:b=""http://schemas.microsoft.com/BizTalk/2003"" attributeFormDefault=""unqualified"" elementFormDefault=""qualified"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:complexType name=""TestType"">
    <xs:attribute name=""Fx2"" type=""xs:string"" />
  </xs:complexType>
</xs:schema>";
            XmlSchema schema1 = XmlSchema.Read(new StringReader(schema1Str), null);
            XmlSchema schema2 = XmlSchema.Read(new StringReader(schema2Str), null);
            XmlSchema schema3 = XmlSchema.Read(new StringReader(schema3Str), null);

            //schema1 has some xs:includes in it. Since all schemas are string based, XmlSchema on its own cannot load automatically
            //load these included schemas. We will resolve these schema locations schema1 and make them point to the correct
            //in memory XmlSchema objects
            ((XmlSchemaExternal)schema1.Includes[0]).Schema = schema3;
            ((XmlSchemaExternal)schema1.Includes[1]).Schema = schema2;

            XmlSchemaSet schemaSet = new XmlSchemaSet();
            schemaSet.XmlResolver = new XmlUrlResolver();
            schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);

            if (schemaSet.Add(schema1) != null)
            {
                //This compile will complain about Undefined complex Type tns:FxType and schemaSet_ValidationEventHandler will be
                //called with this error.
                schemaSet.Compile();
                schemaSet.Reprocess(schema1);
            }
            CError.Compare(warningCount, 0, "Warning Count mismatch!");
            CError.Compare(errorCount, 0, "Error Count mismatch!");
            return;
        }