XmlTextReader.Normalization プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlTextReader.Normalization プロパティの意味・解説 

XmlTextReader.Normalization プロパティ

空白属性値正規化するかどうかを示す値を取得または設定します

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

例外例外
例外種類条件

InvalidOperationException

リーダー閉じているとき (ReadState が ReadState.Closed のとき) にこのプロパティ設定します

解説解説

このプロパティはいつでも変更でき、次の読み取り操作時に有効となります

メモメモ

XmlTextReader を使用して XmlValidatingReader を構築し属性値正規化する場合は、Normalizationtrue設定する必要があります

Normalizationfalse設定すると、数値エンティティチェックする文字範囲無効になりますその結果� などの文字エンティティ許可されます。

属性値正規化について次に説明します

XmlTextReader は、属性正規化または CDATA の正規化だけを実行しますXmlValidatingReader 内にラップされない限りDTD 固有の正規化実行しません。

正規化詳細については、W3C 勧告XML 1.0』を参照してください

使用例使用例

正規化オンにし、次にオフにしたときのリーダー動作次の例に示します

Imports System
Imports System.IO
Imports System.Xml
Imports Microsoft.VisualBasic

public class Sample

  public shared sub Main()

    ' Create the XML fragment to be parsed.
    Dim xmlFrag as string
 = "<item attr1='  test A B C " + Chr(10) & _
                            "   1 2 3'/>" + Chr(10) &
 _
                            "<item attr2='&#01;'/>"
                    

    ' Create the XmlNamespaceManager.
    Dim nsmgr as XmlNamespaceManager = new
 XmlNamespaceManager(new NameTable())

    ' Create the XmlParserContext.
    Dim context as XmlParserContext = new
 XmlParserContext(nothing, nsmgr, nothing,
 XmlSpace.Preserve)

    ' Create the reader.
    Dim reader as XmlTextReader = new
 XmlTextReader(xmlFrag, XmlNodeType.Element, context)

    ' Show attribute value normalization.
    reader.Read()
    reader.Normalization = false
    Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr1"))
    reader.Normalization = true
    Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr1"))

    ' Set Normalization back to false.  This allows the reader to accept
    ' character entities in the &#00; to &#20; range.  If Normalization
 had
    ' been set to true, character entities in this range throw an exception.
    reader.Normalization = false
    reader.Read()
    reader.MoveToContent()
    Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr2"))
  
    ' Close the reader.
    reader.Close()     
  
  end sub
end class
using System;
using System.IO;
using System.Xml;

public class Sample{

  public static void Main(){

    // Create the XML fragment to be parsed.
    string xmlFrag  = 
    @"<item attr1='  test A B C
        1 2 3'/>
      <item attr2='&#01;'/>";                         

    // Create the XmlNamespaceManager.
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(new
 NameTable());

    // Create the XmlParserContext.
    XmlParserContext context = new XmlParserContext(null,
 nsmgr, null, XmlSpace.Preserve);

    // Create the reader.
    XmlTextReader reader = new XmlTextReader(xmlFrag, XmlNodeType.Element,
 context);

    // Show attribute value normalization.
    reader.Read();
    reader.Normalization = false;
    Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr1"));
    reader.Normalization = true;
    Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr1"));

    // Set Normalization back to false.  This allows the reader to accept
    // character entities in the &#00; to &#20; range.  If Normalization
 had
    // been set to true, character entities in this range throw an exception.
    reader.Normalization = false;
    reader.Read();
    reader.MoveToContent();
    Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr2"));
  
    // Close the reader.
    reader.Close();     
  
  }
}
#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   // Create the XML fragment to be parsed.
   String^ xmlFrag = "<item attr1='  test A B C\n"
   "1 2 3'/>\n"
   "<item attr2='&#01;'/>\n";
   
   // Create the XmlNamespaceManager.
   XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( gcnew NameTable );
   
   // Create the XmlParserContext.
   XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::Preserve
 );
   
   // Create the reader.
   XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context
 );
   
   // Show attribute value normalization.
   reader->Read();
   reader->Normalization = false;
   Console::WriteLine( "Attribute value: {0}", reader->GetAttribute(
 "attr1" ) );
   reader->Normalization = true;
   Console::WriteLine( "Attribute value: {0}", reader->GetAttribute(
 "attr1" ) );
   
   // Set Normalization back to false.  This allows the reader to accept
   // character entities in the &#00; to &#20; range.  If Normalization
 had
   // been set to true, character entities in this range throw an exception.
   reader->Normalization = false;
   reader->Read();
   reader->MoveToContent();
   Console::WriteLine( "Attribute value: {0}", reader->GetAttribute(
 "attr2" ) );
   
   // Close the reader.
   reader->Close();
}

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

public class Sample
{
    public static void main(String[]
 args)
    {
        // Create the XML fragment to be parsed.
        String xmlFrag = "<item attr1='  test A B C\n" + "    
    1 2 3'/>\n" 
            + "      <item attr2='&#01;'/>";
        // Create the XmlNamespaceManager.
        XmlNamespaceManager nsMgr = new XmlNamespaceManager(new
 NameTable());
        // Create the XmlParserContext.
        XmlParserContext context = new XmlParserContext(null,
 nsMgr,
            null, XmlSpace.Preserve);
        // Create the reader.
        XmlTextReader reader = new XmlTextReader(xmlFrag, XmlNodeType.Element
,
            context);
        // Show attribute value normalization.
        reader.Read();
        reader.set_Normalization(false);
        Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr1"));
        reader.set_Normalization(true);
        Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr1"));
        // Set Normalization back to false.  This allows the reader
 to accept
        // character entities in the &#00; to &#20; range.  If Normalization
 had
        // been set to true, character entities in this range throw
 an exception.
        reader.set_Normalization(false);
        reader.Read();
        reader.MoveToContent();
        Console.WriteLine("Attribute value:{0}", reader.GetAttribute("attr2"));
        // Close the reader.
        reader.Close();
    } //main 
} //Sample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からXmlTextReader.Normalization プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からXmlTextReader.Normalization プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からXmlTextReader.Normalization プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

XmlTextReader.Normalization プロパティのお隣キーワード
検索ランキング

   

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



XmlTextReader.Normalization プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS