Creates an empty schema.
For a list of all members of this type, see XmlSchemaObject Members.
System.Object
System.Xml.Schema.XmlSchemaObject
Derived classes
[Visual Basic] MustInherit Public Class XmlSchemaObject [C#] public abstract class XmlSchemaObject [C++] public __gc __abstract class XmlSchemaObject [JScript] public abstract class XmlSchemaObject
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
[Visual Basic, C#] The following example displays each schema object.
[Visual Basic] Option Strict Option Explicit Imports System Imports System.Xml Imports System.Xml.Schema Imports System.IO Imports System.Reflection Imports Microsoft.VisualBasic Public Class ValidXSD Public Shared Sub Main() Dim xsd As String = "example.xsd" Dim fs As FileStream Dim schema As XmlSchema Try fs = New FileStream(xsd, FileMode.Open) schema = XmlSchema.Read(fs,new ValidationEventHandler(AddressOf ShowCompileError)) schema.Compile(AddressOf ShowCompileError) If schema.IsCompiled Then DisplayObjects(schema) End If Catch e As XmlSchemaException Console.WriteLine("LineNumber = {0}", e.LineNumber) Console.WriteLine("LinePosition = {0}", e.LinePosition) Console.WriteLine("Message = {0}", e.Message) Console.WriteLine("Source = {0}", e.Source) End Try End Sub 'Main Overloads Private Shared Sub DisplayObjects(o As Object) DisplayObjects(o, "") End Sub 'DisplayObjects Overloads Private Shared Sub DisplayObjects(o As Object, indent As String) Console.WriteLine("{0}{1}", indent, o) Dim property1 As PropertyInfo For Each property1 In o.GetType().GetProperties() If property1.PropertyType.FullName = "System.Xml.Schema.XmlSchemaObjectCollection" Then Dim childObjectCollection As XmlSchemaObjectCollection = CType(property1.GetValue(o, Nothing), XmlSchemaObjectCollection) Dim schemaObject As XmlSchemaObject For Each schemaObject In childObjectCollection DisplayObjects(schemaObject, indent + ControlChars.Tab) Next schemaObject End If Next property1 End Sub 'DisplayObjects Private Shared Sub ShowCompileError(sender As Object, e As ValidationEventArgs) Console.WriteLine("Validation Error: {0}", e.Message) End Sub 'ShowCompileError End Class 'ValidXSD [C#] using System; using System.Xml; using System.Xml.Schema; using System.IO; using System.Reflection; public class ValidXSD { public static int Main() { string xsd = "example.xsd"; FileStream fs; XmlSchema schema; try { fs = new FileStream(xsd, FileMode.Open); schema = XmlSchema.Read(fs, new ValidationEventHandler(ShowCompileError)); schema.Compile(new ValidationEventHandler(ShowCompileError)); if (schema.IsCompiled) { DisplayObjects(schema); } return 0; } catch (XmlSchemaException e) { Console.WriteLine("LineNumber = {0}", e.LineNumber); Console.WriteLine("LinePosition = {0}", e.LinePosition); Console.WriteLine("Message = {0}", e.Message); Console.WriteLine("Source = {0}", e.Source); return -1; } } private static void DisplayObjects(object o) { DisplayObjects(o, ""); } private static void DisplayObjects(object o, string indent) { Console.WriteLine("{0}{1}", indent, o); foreach (PropertyInfo property in o.GetType().GetProperties()) { if (property.PropertyType.FullName == "System.Xml.Schema.XmlSchemaObjectCollection") { XmlSchemaObjectCollection childObjectCollection = (XmlSchemaObjectCollection) property.GetValue(o, null); foreach (XmlSchemaObject schemaObject in childObjectCollection) { DisplayObjects(schemaObject, indent + "\t"); } } } } private static void ShowCompileError(object sender, ValidationEventArgs e) { Console.WriteLine("Validation Error: {0}", e.Message); } }
[Visual Basic, C#] The example uses the example.xsd file as input.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="testGroup">
<xs:choice>
<xs:any namespace="##any"/>
</xs:choice>
</xs:group>
<xs:element name="myElement" >
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:group ref="testGroup" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System.Xml.Schema
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: System.Xml (in System.Xml.dll)