VB.Net by API/System.Xml.Schema/XmlSchemaSequence

Материал из VB Эксперт
Перейти к: навигация, поиск

New XmlSchemaSequence

  
Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Collections
Imports System.Data
Imports System.Windows.Forms

Public Class MainClass
    
    Shared Sub Main()
        Dim Schema As XmlSchema = New XmlSchema()
        Dim ElementBook As New XmlSchemaElement()
        Schema.Items.Add(ElementBook)
        ElementBook.Name = "Book"
        Dim ComplexType As New XmlSchemaComplexType()
        ElementBook.SchemaType = ComplexType
        Dim Sequence As New XmlSchemaSequence()
        ComplexType.Particle = Sequence
        Dim ElementTitle As New XmlSchemaElement()
        ElementTitle.Name = "Title"
        ElementTitle.SchemaTypeName = New XmlQualifiedName("string", _
                                       "http://www.w3.org/2001/XMLSchema")
        Dim ElementPublisher As New XmlSchemaElement()
        ElementPublisher.Name = "Publisher"
        ElementPublisher.SchemaTypeName = New XmlQualifiedName("string", _
                                       "http://www.w3.org/2001/XMLSchema")
        Sequence.Items.Add(ElementTitle)
        Sequence.Items.Add(ElementPublisher)
        Schema.rupile(New ValidationEventHandler(AddressOf ValidationHandler))
        Schema.Write(Console.Out)
    End Sub
    Shared Sub ValidationHandler(ByVal sender As Object, _
                          ByVal args As ValidationEventArgs)
        Console.WriteLine("Schema Validation Failed.")
        Console.WriteLine(args.Message)
    End Sub
End Class