XmlSchemaCollection クラスとは? わかりやすく解説

XmlSchemaCollection クラス

メモ : このクラスは、互換性のために残されています。

XML スキーマ定義言語 (XSD: XML Schema Definition Language) スキーマおよび XDR (XML-Data Reduced) スキーマキャッシュ格納します。このクラス継承できません。

名前空間: System.Xml.Schema
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

<ObsoleteAttribute("Use System.Xml.Schema.XmlSchemaSet for
 schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")>
 _
Public NotInheritable Class
 XmlSchemaCollection
    Implements ICollection, IEnumerable
Dim instance As XmlSchemaCollection
[ObsoleteAttribute("Use System.Xml.Schema.XmlSchemaSet for
 schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public sealed class XmlSchemaCollection : ICollection,
 IEnumerable
[ObsoleteAttribute(L"Use System.Xml.Schema.XmlSchemaSet for
 schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public ref class XmlSchemaCollection sealed
 : ICollection, IEnumerable
/** @attribute ObsoleteAttribute("Use System.Xml.Schema.XmlSchemaSet for
 schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")
 */ 
public final class XmlSchemaCollection implements
 ICollection, IEnumerable
ObsoleteAttribute("Use System.Xml.Schema.XmlSchemaSet for
 schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")
 
public final class XmlSchemaCollection implements
 ICollection, IEnumerable
解説解説
使用例使用例

XmlSchemaCollection使用してXML ドキュメント検証する例を次に示します

Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO

public class ValidXSD 

  public shared sub Main()
 
    Dim sc as XmlSchemaCollection = new
 XmlSchemaCollection()
    AddHandler sc.ValidationEventHandler, AddressOf
 ValidationCallBack
    sc.Add(nothing, "books.xsd")

    if(sc.Count > 0)
      Dim tr as XmlTextReader = new
 XmlTextReader("notValidXSD.xml")
      Dim rdr as XmlValidatingReader = new
 XmlValidatingReader(tr)

      rdr.ValidationType = ValidationType.Schema
      rdr.Schemas.Add(sc)
      AddHandler rdr.ValidationEventHandler, AddressOf
 ValidationCallBack
      while (rdr.Read())
      end while
    end if

  end sub

  private shared sub ValidationCallBack(sender
 as object, e as ValidationEventArgs)
 
    Console.WriteLine("XSD Error: {0}", e.Message)
  end sub

end class
using System;
using System.Xml;
using System.Xml.Schema;
using System.IO;

public class ValidXSD {

  public static void Main()
 {
    XmlSchemaCollection sc = new XmlSchemaCollection();
    sc.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
    sc.Add(null, "books.xsd");

    if(sc.Count > 0)
    {
      XmlTextReader tr = new XmlTextReader("notValidXSD.xml");
      XmlValidatingReader rdr = new XmlValidatingReader(tr);

      rdr.ValidationType = ValidationType.Schema;
      rdr.Schemas.Add(sc);
      rdr.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
      while (rdr.Read());
    }
    
  }

  private static void ValidationCallBack(object
 sender, ValidationEventArgs e) {
    Console.WriteLine("Validation Error: {0}", e.Message);
  }
}
#using <System.Xml.dll>
#using <System.dll>

using namespace System;
using namespace System::Xml;
using namespace System::Xml::Schema;
using namespace System::IO;
public ref class ValidXSD
{
public:
   static void main()
   {
      XmlSchemaCollection^ sc = gcnew XmlSchemaCollection;
      sc->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack
 );
      sc->Add( nullptr, "books.xsd" );
      if ( sc->Count > 0 )
      {
         XmlTextReader^ tr = gcnew XmlTextReader( "notValidXSD.xml" );
         XmlValidatingReader^ rdr = gcnew XmlValidatingReader( tr );
         rdr->ValidationType = ValidationType::Schema;
         rdr->Schemas->Add( sc );
         rdr->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack
 );
         while ( rdr->Read() )
                  ;
      }
   }


private:
   static void ValidationCallBack( Object^
 /*sender*/, ValidationEventArgs^ e )
   {
      Console::WriteLine( "Validation Error: {0}", e->Message );
   }

};

int main()
{
   ValidXSD::main();
}

import System.*;
import System.Xml.*;
import System.Xml.Schema.*;
import System.IO.*;

public class ValidXSD
{
    public static void main(String[]
 args)
    {
        XmlSchemaCollection sc = new XmlSchemaCollection();
        sc.add_ValidationEventHandler(new ValidationEventHandler(
            ValidationCallBack));
        sc.Add(null, "books.xsd");

        if (sc.get_Count() > 0) {
            XmlTextReader tr = new XmlTextReader("notValidXSD.xml");
            XmlValidatingReader rdr = new XmlValidatingReader(tr);

            rdr.set_ValidationType(ValidationType.Schema);
            rdr.get_Schemas().Add(sc);
            rdr.add_ValidationEventHandler(new ValidationEventHandler(
                ValidationCallBack));
            while (rdr.Read()) {
            }
        }
    } //main

    private static void
 ValidationCallBack(Object sender,
        ValidationEventArgs e)
    {
        Console.WriteLine("Validation Error: {0}", e.get_Message());
    } //ValidationCallBack
} //ValidXSD
継承階層継承階層
System.Object
  System.Xml.Schema.XmlSchemaCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlSchemaCollection メンバ
System.Xml.Schema 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「XmlSchemaCollection クラス」の関連用語

XmlSchemaCollection クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlSchemaCollection クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS