I pulling my hair out with is error!
I've used an external source to validate my schema against
the xml and it succeeds without any errors
(http://apps.gotdotnet.com/xmltools/x...tor/Default.as
px) but as soon as I run it through some code it pops up
with that error!
Here's my code:
// Create and setup XML
document
XmlTextWriter
xmlDiskWriter = new XmlTextWriter
(fullyQualifiedFilename,Encoding.UTF8);
xmlDiskWriter.Formatting =
Formatting.Indented; // For easier reading :)
xmlDiskWriter.Indentation
= 4; // Looks even nicer ...
xmlDiskWriter.WriteStartDocument();
// Transform
xslDoc.Transform
(xmlDoc,null,xmlDiskWriter,null);
// Validate CID
try
{
XmlReader xmlRead
= new XmlTextReader(location.ToOSString() + xsdCID);
XmlSchemaCollection xsdDoc = new
XmlSchemaCollection();
XmlValidatingReader xmlValid = new
XmlValidatingReader( xmlDiskWriter.ToString
(),XmlNodeType.Document, null);
xsdDoc.Add
(null,xmlRead);
xmlValid.Schemas.Add(xsdDoc);
// Add validation
event handler
xmlValid.ValidationType = ValidationType.Schema;
xmlValid.ValidationEventHandler += new
ValidationEventHandler(ValidationHandler);
xmlValid.MoveToContent();
while(xmlValid.Read
());
xmlValid.Close();
// Raise
exception, if XML validation fails
if (ErrorsCount >
0)
{
throw new
Exception(ErrorMessage);
}
}
catch(Exception error)
{
// XML Validation
failed
MessageBox.Show
("XML validation failed:" + error.Message, "Error",
MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
Any idea's?