XmlTextReader.Normalization プロパティ
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlTextReader Dim value As Boolean value = instance.Normalization instance.Normalization = value
/** @property */ public boolean get_Normalization () /** @property */ public void set_Normalization (boolean value)
正規化する場合は true。それ以外の場合は false。既定値は false です。


![]() |
---|
Microsoft .NET Framework version 2.0 リリースでは、System.Xml.XmlReader.Create メソッドを使用して XmlReader インスタンスを作成することをお勧めします。これにより、このリリースで導入された新機能を十分に活用できます。詳細については、「XML リーダーの作成」を参照してください。 |
このプロパティはいつでも変更でき、次の読み取り操作時に有効となります。
![]() |
---|
XmlTextReader を使用して XmlValidatingReader を構築し、属性値を正規化する場合は、Normalization を true に設定する必要があります。 |
Normalization を false に設定すると、数値エンティティをチェックする文字範囲も無効になります。その結果、� などの文字エンティティが許可されます。
-
空白文字 (#x20、#xD、#xA、#x9) の場合は、正規化した値に #x20 を付け加えます外部解析エンティティの一部または内部解析エンティティのリテラル エンティティ値である "#xD#xA" シーケンスに対しては、単一の #x20 だけが付け加えられます。
-
宣言された値が CDATA でない場合は、前後の空白 (#x20) 文字をすべて破棄し、連続した空白 (#x20) 文字を単一の空白 (#x20) 文字に置き換えます。
XmlTextReader は、属性の正規化または CDATA の正規化だけを実行します。XmlValidatingReader 内にラップされない限り、DTD 固有の正規化は実行しません。

正規化をオンにし、次にオフにしたときのリーダーの動作を次の例に示します。
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=''/>" ' 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 � to  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=''/>"; // 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 � to  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=''/>\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 � to  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=''/>"; // 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 � to  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

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlTextReader.Normalization プロパティを検索する場合は、下記のリンクをクリックしてください。

- XmlTextReader.Normalization プロパティのページへのリンク