xmlns: m = "http://www.MangoDSP.com/mav/wsdl" en tant que fichier local: "ma.wsdl" xmlns: m0 = "http://www.MangoDSP.com/schema "as localfile:" MaTypes.xsd "Comment valider un document xml avec plusieurs schémas xml
comment puis-je le valider.
xmlns: m = "http://www.MangoDSP.com/mav/wsdl" en tant que fichier local: "ma.wsdl" xmlns: m0 = "http://www.MangoDSP.com/schema "as localfile:" MaTypes.xsd "Comment valider un document xml avec plusieurs schémas xml
comment puis-je le valider.
Je n'ai pas fait cela depuis un moment (des années, vraiment) et encore une fois je poste à partir de mon ordinateur portable Linux, alors s'il vous plaît pardonner le flou.
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);
}
Vous devrez également effectuer une gestion des erreurs et un nettoyage des ressources.
MERCI je vais l'essayer. –
Comment valider un document XML avec un seul schéma XML? –
Souhaitez-vous publier le fichier XML? Postez-le, puis sélectionnez le XML et appuyez sur Ctrl-K (le bouton avec 1001010). –