Share via


Attribute Value Normalization

The Normalization property in the XmlTextReader class specifies whether the parser should perform white space normalization and attribute normalization. This property, set on a non-validating parser, is defined in the World Wide Web Consortium (W3C) Extensible Markup Language (XML) Version 1.0 Recommendation, Attribute-Value Normalization section, located at www.w3.org/TR/2000/REC-xml-20001006.html\#AVNormalize. The default setting for the Normalization property is false. When false, the XmlTextReader allows character entities like � because this flag also turns off character range checking for numeric entities.

Note

In the .NET Framework version 2.0, the recommended practice is to create XmlReader instances using the XmlReaderSettings class and the Create method. This allows you to take full advantage of all the new features introduced in the .NET Framework 2.0. For more information, see Creating XML Readers.

XmlReader instances created using the Create method always normalize new lines and attribute values according to the XML specification.

Normalization

The WC3 recommendation specifies that before the value of an attribute is passed to an application or checked for validity, it must be normalized as follows:

  • For a character reference, append the referenced character to the attribute value.

  • For an entity reference, recursively process the replacement text of the entity.

  • For white space characters (#x20, #xD, #xA, #x9), append #x20 to the normalized value, with the exception that a single #x20 is appended for a #xD#xA sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity.

  • Process other characters by appending them to the normalized value.

  • If the declared value is not CDATA, then discard any leading and trailing space (#x20) characters and replace sequences of space (#x20) characters by a single space (#x20) character.

See Also

Concepts

Reading XML with the XmlReader

Other Resources

Using the XmlReader Class