Your ATML should validate so that you will not break another vendor's software. However, just because your ATML validates that does not mean it is correct and complete. The validation software does not catch everything. And even if your ATML is correct and complete that doesn't mean it will work with other software that you didn't write. The ATML standards can be
interpreted--correctly--in more than one way. We are all going to have to work together and be able to adapt
our software to whatever we receive from other vendors.
Our first attempt at
creating ATML from ATLAS produced 30 pages of validation
errors! After the initial shock, we realized that most of the
errors were repeated. So as we fixed each problem, 3 or 4 pages of
errors would disappear. We found it useful to make our own
validation program to print the errors on paper. It will be
important to have your own validation program to be sure that a
vendor's creative use of ATML does not break your software.
Here is some sample code you are welcome to use: * This program
reads XML from the console input, validates it, and reports
errors/warnings on the console output
*/
using
System;
using
System.Xml;
using
System.Xml.Schema;
namespace SimpleValidator
{
class Program
{
static void
Main(string[] args)
{
// set up to validate the
XML
XmlReaderSettings settings = new
XmlReaderSettings();
settings.ValidationType = ValidationType.Schema; //
Validation and type assignment is performed using an XML Schema
definition language (XSD) schema
settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
// Report schema validation warnings encountered
during validation.
settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
// Process schema location hints
(xsi:schemaLocation,
xsi:noNamespaceSchemaLocation)
settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
// Process inline schemas encountered during
validation.
settings.ValidationEventHandler += ValidationHandler; // callback when the reader encounters validation
errors
// create a reader on the console input
using the settings above
XmlReader reader = XmlReader.Create(Console.In, settings);
try
{
// do until end of
file
while (true)
{
try
{
// read a node - if false we're
done
if (!reader.Read()) break;
}
catch
(Exception
exc)
{
// there is a problem so print it on the
console
Console.WriteLine("{0}:
{1}", "Error",
exc.Message);
}
}
}
finally
{
// close the
reader
reader.Close();
}
}
static void ValidationHandler(Object sender, ValidationEventArgs vargs)
{
// there is a problem so print it on the
console
Console.WriteLine("{0}: {1}", vargs.Severity,
vargs.Message);
}
}
} |
_text_