C # in a Nutshell, Second Edition

XmlValidatingReader

System.Xml (system.xml.dll) class

This class is an XML reader that supports DTD and schema validation. The type of validation to perform is contained in the ValidationType property, which can be DTD , Schema , XDR , or Auto . Auto is the default and determines which type of validation is required, if any, based on the document. If the DOCTYPE element contains DTD information, that is used. If a schema attribute exists or there is an inline <schema> , that schema is used.

This class implements an event handler that you can set to warn of validation errors during Read( ) operations. Specifically, a delegate instance of type System.Xml.Schema.ValidationEventHandler can be set for the ValidationEventHandler event in this class. This delegate instance is invoked whenever the XmlValidatingReader finds an schema-invalid construct in the XML document it is reading, giving the delegate a chance to perform whatever error-handling is appropriate. If no event handler is registered, an XmlException is thrown instead on the first error.

public class XmlValidatingReader : XmlReader, IXmlLineInfo { // Public Constructors public XmlValidatingReader (System.IO.Stream xmlFragment , XmlNodeType fragType , XmlParserContext context ); public XmlValidatingReader (string xmlFragment , XmlNodeType fragType , XmlParserContext context ); public XmlValidatingReader (XmlReader reader ); // Public Instance Properties public override int AttributeCount {get; } // overrides XmlReader public override string BaseURI {get; } // overrides XmlReader public override bool CanResolveEntity {get; } // overrides XmlReader public override int Depth {get; } // overrides XmlReader public Encoding Encoding {get; } public EntityHandling EntityHandling {set; get; } public override bool EOF {get; } // overrides XmlReader public override bool HasValue {get; } // overrides XmlReader public override bool IsDefault {get; } // overrides XmlReader public override bool IsEmptyElement {get; } // overrides XmlReader public override string LocalName {get; } // overrides XmlReader public override string Name {get; } // overrides XmlReader public bool Namespaces {set; get; } public override string NamespaceURI {get; } // overrides XmlReader public override XmlNameTable NameTable {get; } // overrides XmlReader public override XmlNodeType NodeType {get; } // overrides XmlReader public override string Prefix {get; } // overrides XmlReader public override char QuoteChar {get; } // overrides XmlReader public XmlReader Reader {get; } public override ReadState ReadState {get; } // overrides XmlReader public XmlSchemaCollection Schemas {get; } public object SchemaType {get; } public override string this [int i ]{get; } // overrides XmlReader public override string this [string name ]{get; } // overrides XmlReader public override string this [string name , string namespaceURI ]{get; } // overrides XmlReader public ValidationType ValidationType {set; get; } public override string Value {get; } // overrides XmlReader public override string XmlLang {get; } // overrides XmlReader public XmlResolver XmlResolver {set; } public override XmlSpace XmlSpace {get; } // overrides XmlReader // Public Instance Methods public override void Close ( ); // overrides XmlReader public override string GetAttribute (int i ); // overrides XmlReader public override string GetAttribute (string name ) // overrides XmlReader public override string GetAttribute (string localName , string namespaceURI ) // overrides XmlReader public override string LookupNamespace (string prefix ); // overrides XmlReader public override bool MoveToAttribute (string name ); // overrides XmlReader public override bool MoveToAttribute (string localName , string namespaceURI ) // overrides XmlReader public override void MoveToAttribute (int i ); // overrides XmlReader public override bool MoveToElement ( ); // overrides XmlReader public override bool MoveToFirstAttribute ( ); // overrides XmlReader public override bool MoveToNextAttribute ( ); // overrides XmlReader public override bool Read ( ); // overrides XmlReader public override bool ReadAttributeValue ( ); // overrides XmlReader public override string ReadString ( ); // overrides XmlReader public object ReadTypedValue ( ); public override void ResolveEntity ( ); // overrides XmlReader // Events public event ValidationEventHandler ValidationEventHandler ; }

Hierarchy

System.Object XmlReader XmlValidatingReader(IXmlLineInfo)

Категории