"William Johnston" <wi******@tenbase2.comwrote:
>
Thanks again for your reply.
The init code for the validating XML reader is:
StreamReader stream = new StreamReader(strFilename);
// Create the XmlSchemaSet class.
DVDXmlSchemaSet sc = new DVDXmlSchemaSet(strTargetNamespace, strSchemaFilename);
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.ValidationFlags |= XmlSchemaValidationFlags.None;
settings.Schemas = sc;
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
reader = XmlReader.Create(stream, settings);
/// <summary>
/// schema filename
/// </summary>
private static string strTargetNamespace = "urn:DVDTimestamps";
/// <summary>
/// schema filename
/// </summary>
private static string strSchemaFilename = "DVDTimestampXmlSchema.xsd";
The DVDXmlSchemaSet class has a base class of XmlSchemaSet and has a constructor of:
class DVDXmlSchemaSet : MyXmlSchemaSet
{
public DVDXmlSchemaSet(string strTargetNamespace, string strFileName)
: base(strTargetNamespace, strSchemaPath, strFileName)
{
}
/// <summary>
/// field that contains the XML schema path
/// </summary>
public static string strSchemaPath = "G:\\DVD\\MyPrograms output\\xml schemas\\";
}
Finally, the MyXmlSchemaSet constructor is:
public MyXmlSchemaSet(string strTargetNamespace, string strPath, string strFilename) : base()
{
object[] formatParams = new object[2];
formatParams[0] = strPath;
formatParams[1] = strFilename;
string strSchemaFile = string.Format("{0}{1}", formatParams);
Add(strTargetNamespace, strSchemaFile);
}
The exact exception and error message is:
System.Xml.Schema.XmlSchemaValidationException: "The 'http://tenbase2.com/DVDTimestamps:schemaLocation' attribute is not declared."
Regards,
William Johnston