13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table 3-1: Key Properties of the XmlValidat<strong>in</strong>gReader ClassPropertySchemaTypeValidationTypeXmlResolverDescriptioncollection of preloaded XDRs and XSDs. Schemapreload<strong>in</strong>g is a trick used to speed up the validationprocess. Schemas, <strong>in</strong> fact, are cached, and there is noneed to load them every time.Gets the schema object that represents the currentnode <strong>in</strong> the underly<strong>in</strong>g reader. This property is relevantonly <strong>for</strong> XSD validation. The object describes whetherthe type of the node is one of the built-<strong>in</strong> XSD types ora user-def<strong>in</strong>ed simple or complex type.Indicates the type of validation to per<strong>for</strong>m. Feasiblevalues come from the ValidationType enumeration:Auto, None, DTD, XDR, and Schema.Sets the XmlResolver object used <strong>for</strong> resolv<strong>in</strong>g externalDTD and schema location references. TheXmlResolver is also used to handle any import or<strong>in</strong>clude elements found <strong>in</strong> XSD schemas.The validat<strong>in</strong>g reader uses the underly<strong>in</strong>g reader to move around the document andimplements most of its XmlReader-derived properties by simply mirror<strong>in</strong>g thecorrespond<strong>in</strong>g properties of the worker reader.XmlValidat<strong>in</strong>gReader MethodsTable 3-2 lists the methods exposed by the XmlValidat<strong>in</strong>gReader class that are eithernew or whose behavior significantly differs from the correspond<strong>in</strong>g methods of theXmlReader class.Table 3-2: Public Methods of the XmlValidat<strong>in</strong>gReader ClassMethodReadReadTypedValueSkipDescriptionThe underly<strong>in</strong>g reader moves to the next node. At thesame time, the validat<strong>in</strong>g reader gets the node<strong>in</strong><strong>for</strong>mation and validates it us<strong>in</strong>g the schema<strong>in</strong><strong>for</strong>mation and the previously cached <strong>in</strong><strong>for</strong>mation.Gets the value <strong>for</strong> the underly<strong>in</strong>g node as a commonlanguage runtime (CLR) type. The mapp<strong>in</strong>g can takeplace only <strong>for</strong> XSDs. Whenever a direct mapp<strong>in</strong>g is notpossible, the node value is returned as a str<strong>in</strong>g.Skips the children of the current node <strong>in</strong> the underly<strong>in</strong>greader. You can't skip over badly <strong>for</strong>med <strong>XML</strong> text,however. In the XmlValidat<strong>in</strong>gReader class, the Skipmethod also validates the skipped content.As you can see, the programm<strong>in</strong>g <strong>in</strong>terface of the XmlValidat<strong>in</strong>gReader class does notexplicitly provide a s<strong>in</strong>gle method that can validate the entire contents of a document.The validat<strong>in</strong>g reader works <strong>in</strong>crementally, node by node, as the underly<strong>in</strong>g readerdoes. Each validation error found along the way results <strong>in</strong> a particular event notificationbe<strong>in</strong>g returned to the caller application. The application is then responsible <strong>for</strong> def<strong>in</strong><strong>in</strong>gan ad hoc event handler and behav<strong>in</strong>g as needed.64

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!