in SmvLibrary/Utility.cs [189:242]
public static bool ValidateXmlFile(string schemaPath, TextReader configFile)
{
XmlReader reader;
Log.LogInfo("Validating XML against schema: " + schemaPath);
// Load and validate the XML document.
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add("", schemaPath);
settings.ValidationType = ValidationType.Schema;
try
{
reader = XmlReader.Create(configFile, settings);
}
catch (FileNotFoundException)
{
Log.LogError("Config file not found. Put it in the current directory or pass it in the arguments [/config:<PATH TO CONFIG FILE>]");
return false;
}
ValidationEventHandler handler = new ValidationEventHandler(ValidationEventHandlerCallback);
XmlDocument doc = new XmlDocument();
try
{
doc.Load(reader);
doc.Validate(handler);
}
catch (Exception e)
{
Log.LogError(e.ToString());
return false;
}
// We do some validation ourselves because we can't use XSD 1.1 yet.
foreach (XmlNode actionNode in doc.SelectNodes("SMVConfig/Analysis/Action"))
{
foreach (XmlNode copyArtifactNode in actionNode.SelectNodes("CopyArtifact"))
{
string type = Environment.ExpandEnvironmentVariables(copyArtifactNode.Attributes["type"].Value).ToLowerInvariant();
string entity = Environment.ExpandEnvironmentVariables(copyArtifactNode.Attributes["entity"].Value).ToLowerInvariant();
if ((type == "rawcfgf" && entity != "compilationunit") ||
(type == "li" && entity == "functionunit") ||
(type == "bpl" && entity == "compilationunit"))
{
Log.LogError(String.Format(CultureInfo.InvariantCulture, "\"type\" attribute cannot have value \"{0}\" when \"entity\" attribute has value \"{1}\".", type, entity));
return false;
}
}
}
return true;
}