xmlns:m =“http://www.MangoDSP.com/mav/wsdl”as localfile:“ma.wsdl” xmlns:m0 =“http://www.MangoDSP.com/schema”作为localfile:“MaTypes.xsd”
我如何验证它。
答案 0 :(得分:1)
我有一段时间没有这样做(多年,真的),我再次从我的Linux笔记本电脑上发帖,所以请原谅模糊。
private bool isValid;
private ArrayList exceptionList;
public bool Validate()
{
isValid = true;
exceptionList = new ArrayList();
XmlTextReader reader;
XmlSchema schema;
XmlSchemaCollection schemas = new XmlSchemaCollection();
reader = new XmlTextReader( "schema file 1" );
schema = XmlSchema.Read( reader, new ValidationEventHandler( ValidationError ) );
schemas.Add( schema );
reader = new XmlTextReader( "schema file 2" );
schema = XmlSchema.Read( reader, new ValidationEventHandler( ValidationError ) );
schemas.Add( schema );
reader = new XmlTextReader( "validate this file" );
XmlValidatingReader validatingReader;
validatingReader = new XmlValidatingReader( reader );
validatingReader.ValidationEventHandler += new ValidationEventHandler( ValidationError );
validatingReader.Schemas.Add( schemas );
isValid = true;
exceptionList = new ArrayList();
while ( validatingReader.Read() );
return isValid;
}
private void ValidationError( object sender, ValidationEventArgs e )
{
isValid = false;
exceptionList.Add( e.Exception );
}
您还需要进行一些错误处理和资源清理。