System.Xml.Tests.TC_SchemaSet_Compile.TFS_470021 C# (CSharp) Méthode

TFS_470021() private méthode

private TFS_470021 ( ) : void
Résultat void
        public void TFS_470021()
        {
            string cham = @"<?xml version='1.0' encoding='utf-8' ?>
<xs:schema id='a0'
                  elementFormDefault='qualified'
                  xmlns:xs='http://www.w3.org/2001/XMLSchema'>
  <xs:complexType name='ctseq1_a'>
    <xs:sequence>
      <xs:element name='foo'/>
    </xs:sequence>
    <xs:attribute name='abt0' type='xs:string'/>
  </xs:complexType>
  <xs:element name='gect1_a' type ='ctseq1_a'/>
</xs:schema>";
            string main = @"<?xml version='1.0' encoding='utf-8' ?>
<xs:schema id='m0'
                  targetNamespace='http://tempuri.org/chameleon1'
                  elementFormDefault='qualified'
                  xmlns='http://tempuri.org/chameleon1'
                  xmlns:mstns='http://tempuri.org/chameleon1'
                  xmlns:xs='http://www.w3.org/2001/XMLSchema'>
  <xs:include schemaLocation='cham.xsd' />

  <xs:element name='root'>
    <xs:complexType>
      <xs:sequence maxOccurs='unbounded'>
        <xs:any namespace='##any' processContents='lax'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>";
            using (XmlWriter w = XmlWriter.Create("cham.xsd"))
            {
                using (XmlReader r = XmlReader.Create(new StringReader(cham)))
                    w.WriteNode(r, true);
            }
            XmlSchemaSet ss = new XmlSchemaSet();
            ss.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);

            ss.Add(null, XmlReader.Create(new StringReader(cham)));
            ss.Add(null, XmlReader.Create(new StringReader(main)));
            ss.Compile();

            Assert.Equal(ss.Count, 2);
            foreach (XmlSchemaElement e in ss.GlobalElements.Values)
            {
                _output.WriteLine(e.QualifiedName.ToString());
                XmlSchemaComplexType type = e.ElementSchemaType as XmlSchemaComplexType;
                XmlSchemaSequence seq = type.ContentTypeParticle as XmlSchemaSequence;
                foreach (XmlSchemaObject child in seq.Items)
                {
                    if (child is XmlSchemaElement)
                        _output.WriteLine("\t" + (child as XmlSchemaElement).QualifiedName);
                }
            }
            Assert.Equal(warningCount, 0);
            Assert.Equal(errorCount, 0);
            return;
        }
    }