Как я могу использовать Saxon Home Edition (HE) 9.4 для проверки XML на XSD?
Нужна ли версия Enterprise для этого базового действия, о чем свидетельствует сообщение об ошибке?Вот код, который я использую.
private void btnSaxonTest3_Click(object sender, EventArgs e)
// validate xml against xsd and show multiple errors
{
try
{
SetGlobalVariables();
Saxon.Api.Processor proc = new Processor(true);
//this is the property to set for multiple errors
//proc.SetProperty("net.sf.saxon.lib.FeatureKeys.VALIDATION_WARNINGS", "true"); //Enterprise function only?
SchemaManager schemaManager = proc.SchemaManager;
FileStream xsdFs = new FileStream(GvXSDFullPath, FileMode.Open);
schemaManager.Compile(XmlReader.Create(xsdFs));
SchemaValidator validator = schemaManager.NewSchemaValidator();
FileStream xmlFs = new FileStream(GvXMLFullPath, FileMode.Open);
validator.SetSource(XmlReader.Create(xmlFs));
validator.ErrorList = new ArrayList();
try
{
validator.Run();
}
catch (Exception)
{
AddMsg("Instance validation failed with " + validator.ErrorList.Count + " errors");
foreach (StaticError error in validator.ErrorList)
{
AddMsg("At line " + error.LineNumber + ": " + error.Message);
}
txtResults.Text = GvResults;
return;
} // try catch
}
catch (Exception ex)
{
AddMsg(ex.ToString());
}
AddMsg("Process completed");
txtResults.Text = GvResults;
}