thank you so much, Martin. this demonstrated a few key concepts that i
think the MSDN library was not making clear.
i do have one question though about your example. i do not see anywhere
that the Schema is being added to a Schema collection, and the
validation type of the ValidatingReader being changed to Schema? i
believe the default is simply DTD. would you be willing to show how to
add a Schema validation?
thanks again,
jason
> i do have one question though about your example. i do not see anywhere
> that the Schema is being added to a Schema collection,
The XML document references the schema via xsi:noNamespaceSchemaLocation
so that there is no need to a add the schema explictly.
> and the
> validation type of the ValidatingReader being changed to Schema? i
> believe the default is simply DTD.
The default is Auto and that does whatever is possible, if a DTD is
linked in via a DOCTYPE declaration it validates against the DTD, if a
schema or a schemas are present it validates against the schema(s).
> would you be willing to show how to
> add a Schema validation?
As said the example does schema validation by using the schema given in
the xsi:noNamespaceSchemaLocation but if you want to add the schema
manually then it looks like this
NameTable nameTable = new NameTable();
XmlNamespaceManager namespaceManager = new
XmlNamespaceManager(nameTable);
XmlParserContext parserContext = new XmlParserContext(null,
namespaceManager, null, XmlSpace.None);
XmlValidatingReader xmlValidator = new
XmlValidatingReader(xmlMarkup, XmlNodeType.Document, parserContext);
xmlValidator.ValidationEventHandler += new
ValidationEventHandler(ValidationHandler);
xmlValidator.Schemas.Add("", "test2005042101Xsd.xml");
where the first argument is "" for no namespace and where
"test2005042101Xsd.xml" is the (relative) URL where the schema is.
After that you can use the Read method as in other examples.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
jason - 22 Apr 2005 14:08 GMT
this all makes sense, thanks again Martin.
on last question about appropriate use of manual Schema addition: if
you didn't control the source of the XML document, and could not be
certain that it included the schema reference, would that be a good
reason to add the Schema manually, to make certain it is validated
using the schema?
my code is now reporting Schema errors with the manual schema addition.
the severity is only warning, which i find interesting, but that is
enough to confirm the validity of the doucment, and that's what i was
shooting for.
thanks again,
jason
Martin Honnen - 23 Apr 2005 12:36 GMT
> on last question about appropriate use of manual Schema addition: if
> you didn't control the source of the XML document, and could not be
> certain that it included the schema reference, would that be a good
> reason to add the Schema manually, to make certain it is validated
> using the schema?
Yes, if you want to make sure a certain schema or certain schemas are
used for validation then you have to add them yourself. This has also
the advantage that the schemas are cached so you can use the same reader
again and again without any need to reload the schemas.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/