For this example, the schema is referenced in the XML document through the uses DTD or schema information found in the XML document, if any, or creates a non-validating parser, otherwise. NET, the validation mechanism consists of the interaction of two methods (see Listing 3): one that instantiates the required classes and executes the validation process, and a second callback method that is called each time a validation event occurs. You must provide the code for this event handler to do appropriate error-handling and/or logging.
The XML document being validated in this example (see Listing 1) represents a one-record result set from a SQL Server 2000 query that uses the FOR XML EXPLICIT syntax to generate a well-formed XML document. NET" for more about this topic.) The XML Schema (see Listing 2) defines the elements (along with their attributes, data types, and ranges) that will be considered legal for documents that are valid with respect to this schema.
Although the Xml Validating Reader class inherits from the base class Xml Reader, it really implements internally only a very small set of all the required functionalities.
Because the class works on top of an existing XML reader, many methods and properties are just mirrored.
Error indicates that a serious validation error occurred when processing the document against a DTD, XDR or a XSD schema.
If the current instance of the Xml Validating Reader class has no validation event handler set, then an exception is thrown.