PDA

View Full Version : مبتدی: مشکل در اعتبارسنجی فایل xml با توجه به schema آن در فایل xsd



pooyanre
جمعه 09 آبان 1393, 20:56 عصر
سلام.
من مشکل در اعتبارسنجی فایل xml با توجه به schema آن در فایل xsd دارم.
وقتی کدمو اجرا می کنم این ارور میده:


Wildcard '##any' allows element 'http://www.irica.com/ECEP/1383-12/SendSchema:Attachments', and causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence


کدم اینه :



try
{
XmlReaderSettings Xsettings = new XmlReaderSettings();
Xsettings.ValidationType = ValidationType.Schema;


openFileDialog1.Title = "The address of the xsd file";
openFileDialog1.Filter = "xsd files|*.xsd";
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName == "")
{
MessageBox.Show("Operation was cancelled.");
}
else
{
Xsettings.Schemas.Add(null, openFileDialog1.FileName);


openFileDialog1.FileName = "";
openFileDialog1.Title = "The address of the xml file";
openFileDialog1.Filter = "xml files|*.xml";
openFileDialog1.ShowDialog();


if (openFileDialog1.FileName == "")
{
MessageBox.Show("Operation was cancelled.");
}
else
{
XmlDocument document = new XmlDocument();
document.Load(openFileDialog1.FileName);


XmlReader reader = XmlReader.Create(new StringReader(document.InnerXml), Xsettings);


while (reader.Read()) ;
MessageBox.Show("Validation was successful.");
}
}
}
catch (Exception ex)
{
MessageBox.Show("The XML file is not valid.\n" + ex.Message);
}




کد فایل xsd :
125147

کد فایل xml :
125148

لطفا کمک ...