XmlSchemaInference クラス
アセンブリ: System.Xml (system.xml.dll 内)


System.Xml.Schema 名前空間内の XmlSchemaInference クラスを使用すると、XML ドキュメントの構造から XML スキーマ定義言語 (XSD) スキーマを推論できます。XmlSchemaInference クラスは、XML ドキュメントを検証できる XML スキーマを出力します。
XmlSchemaInference クラスは、W3C XML 標準および XML スキーマ標準をサポートします。これは、新しいスキーマを推論したり既存のスキーマを詳細に指定したりするために使用できます。

次の例では、XML ファイルを入力として取得し、サンプル XML を検証できるスキーマを生成します。
Dim reader As XmlReader = XmlReader.Create("contosoBooks.xml") Dim schemaSet As XmlSchemaSet = New XmlSchemaSet() Dim schema As XmlSchemaInference = New XmlSchemaInference() schemaSet = schema.InferSchema(reader) For Each s As XmlSchema In schemaSet.Schemas() s.Write(Console.Out) Next
XmlReader reader = XmlReader.Create("contosoBooks.xml"); XmlSchemaSet schemaSet = new XmlSchemaSet(); XmlSchemaInference schema = new XmlSchemaInference(); schemaSet = schema.InferSchema(reader); foreach (XmlSchema s in schemaSet.Schemas()) { s.Write(Console.Out); }
<bookstore xmlns="http://www.contoso.com/books"> <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0"> <title>The Autobiography of Benjamin Franklin</title> <author> <first-name>Benjamin</first-name> <last-name>Franklin</last-name> </author> <price>8.99</price> </book> <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2"> <title>The Confidence Man</title> <author> <first-name>Herman</first-name> <last-name>Melville</last-name> </author> <price>11.99</price> </book> <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6"> <title>The Gorgias</title> <author> <name>Plato</name> </author> <price>9.99</price> </book> </bookstore>
<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.contoso.com/books" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="bookstore"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="book"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string" /> <xs:element name="author"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="name" type="xs:string" /> <xs:element minOccurs="0" name="first-name" type="xs:string" /> <xs:element minOccurs="0" name="last-name" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="price" type="xs:decimal" /> </xs:sequence> <xs:attribute name="genre" type="xs:string" use="required" /> <xs:attribute name="publicationdate" type="xs:date" use="required" /> <xs:attribute name="ISBN" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

System.Xml.Schema.XmlSchemaInference


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- XmlSchemaInference クラスのページへのリンク