我在.net2.0里用XmlReader来验证,但是把Schema加载到XmlSet里的时候却有问题,到底是怎么回事?/// <summary>
/// schemas used for cross validation of the single DTM descriptions
/// </summary>
        private XmlSchemaSet m_schemas;/// <summary>
/// read in all the XML schemas from the standard schema directory
/// keep them in the cached collection
/// </summary>
private void FillSchemaCollection(string schemaPath)
{
try
{
string[] fileEntries = Directory.GetFiles(schemaPath, "*.xml"); // now load in all these files into the cached schema collection
foreach(string file in fileEntries)
{
try
{
AddSchema(file);
}
catch
{
// ignore now, cross references generate errors
}
}
}
catch (Exception e)
{
throw new Exception("Basic XML validation error. The schema file is incorrect!", e);
}}// -----------------------------------------------------------------------------------------
/// <summary>
/// Function to externally add members to the schema cache.
/// Errors must be caught per exception.
/// </summary>
/// <param name="fullFileName">Name of file containing schema.</param>
/// <returns>TRUE if add to cache was successful.</returns>
internal bool AddSchema(string fullFileName)
{
FileInfo fileInfo = new FileInfo(fullFileName);
string schema = new StringBuilder("x-schema:").Append(fileInfo.Name).ToString(); // add schema also in case that there is already such a schema added
m_schemas.Add(schema, fileInfo.FullName); return true;
}