Xml Schema schema = new Xml Schema(); The Xml Schema constructor should only appear in applications that are directly programming the Schema Object Model (SOM). Source Uri = str Xsd; The second solution is to use the static Read() method of Xml Schema. Add( schema); The null argument I passed to Read() is an optional Validation- Event Handler that allows you to receive notifications of any warnings or errors caused while loading the XML schema document.Whenever this line appears in an application that is just validating an instance document against a ready-made schema, it's got to raise a brightly colored -- if not red -- flag. Source Uri = str Xsd; It's probably a common misconception that setting Source Uri causes a schema to be loaded; this is not actually what happens. Nine times out of 10, this is always what you want to do instead of using the Xml Schema() constructor when you're validating an instance document against an existing XML schema document. Read( new Xml Text Writer( str Xsd), null); schema. Either of these approaches should allow you to see that the schema document validates your instance document without any validation errors.
The example is a very simple calculator that calculates the square of the number (the number multiplied by itself) entered by the user.When external document type definitions (DTDs) or schemas are needed for validation, the Xml Validating Reader.Xml Resolver property sets the Xml Resolver object to use for resolving external resources.Although it's not typically a good practice to skip into implementation without sufficient preparation, in the particular domain of our tutorial we can do so safely.In fact this will give you a bird view picture of the subject that will make the comprehension of the rest of the tutorial easier.