This documentation is archived and is not being maintained.

Building an OASIS-Conformant Reader

.NET Framework 1.1

The Organization for the Advancement of Structured Information Standards, OASIS, provides conformance tests based on public standards for Standard Generalized Markup Language (SGML), Extensible Markup Language (XML), and other structured information processing. For more information about OASIS conformance tests and the OASIS mission and charter, see

To build a conformant reader that is capable of testing the OASIS conformance test suites, all default settings for XmlTextReader and XmlValidatingReader are required, with the following exceptions:

  • In the XmlTextReader, set Normalization to true (the default is false).
  • In the XmlValidatingReader, assign a ValidationCallback handler (by default the reader throws exceptions).
  • Set the XmlValidatingReader to ValidationType.DTD (the default is Auto).

The following example shows an OASIS-conformant reader that takes an XML file as input.

Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.Schema

Class ConformantReader
   Private Sub ValidationCallback(sender As Object, args As ValidationEventArgs)
      Console.WriteLine("++++++++++++++ ValidationCallback ++++++++++++++")
      Console.WriteLine("Error Message: {0}", args.Message)
      Console.WriteLine("Severity: {0}", args.Severity)
   End Sub 'ValidationCallback
   Public Sub TraceFile(app_args() As String)
      Dim vrdr As XmlValidatingReader = Nothing
      Dim rdr As XmlTextReader = Nothing
      Dim InputFile As String = app_args(0)
         rdr = New XmlTextReader(InputFile)
         'Default XmlTextReader settings.
         rdr.WhitespaceHandling = WhitespaceHandling.All
         rdr.Namespaces = true
         rdr.Normalization = True
         vrdr = New XmlValidatingReader(rdr)
         'Default XmlValidatingReader settings.
          vrdr.EntityHandling = EntityHandling.ExpandEntities
          vrdr.ValidationType = ValidationType.DTD
          AddHandler vrdr.ValidationEventHandler, AddressOf ValidationCallBack
         While vrdr.Read()
            If vrdr.NodeType = XmlNodeType.EntityReference Then
            End If
         End While
         Console.WriteLine("Reading of {0} completed.", InputFile)
      Catch e As XmlException
         If Not (vrdr Is Nothing) Then
         End If
         If Not (rdr Is Nothing) Then
         End If
         Console.WriteLine("++++++++++++++ Exception ++++++++++++++")
      End Try
   End Sub 'TraceFile
   Public Shared Function Main(args() As String) As Integer
      Dim RunRdr As New ConformantReader()
      Return 0
   End Function 'Main
End Class 'ConformantReader
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;

class ConformantReader {
    private void ValidationCallback(object sender, ValidationEventArgs args ) {
        Console.WriteLine("++++++++++++++ ValidationCallback ++++++++++++++");

    public void TraceFile(string[] app_args) {
        XmlValidatingReader vrdr = null;
        XmlTextReader rdr = null;
        string InputFile = app_args[0];

        try {
            rdr = new XmlTextReader(InputFile);
            /* Default XmlTextReader settings.
            rdr.WhitespaceHandling = WhitespaceSetting.All;
            rdr.Namespaces = true;
            rdr.Normalization = true;

            vrdr = new XmlValidatingReader(rdr);
            /* Default XmlValidatingReader settings.
            vrdr.EntityHandling = EntityHandling.ExpandEntities;
            vrdr.ValidationType = ValidationType.DTD;
            vrdr.ValidationEventHandler += new ValidationEventHandler(this.ValidationCallback);

            while (vrdr.Read()) {                        
                if (vrdr.NodeType == XmlNodeType.EntityReference) {

            Console.WriteLine("\nReading of {0} completed.",InputFile);
        catch(XmlException e) {
            if ( vrdr != null ) vrdr.Close();
            if ( rdr != null) rdr.Close();
            Console.WriteLine("++++++++++++++ Exception ++++++++++++++");

    public static int Main(string[] args) {
        ConformantReader RunRdr = new ConformantReader();
        return 0;

The following XML file is passed in with the preceding code example.

<!--XML file using a DTD-->
<!DOCTYPE bookstore [
  <!ELEMENT bookstore (cd)*> 
  <!ELEMENT cd (title,artist,price)>
  <!ELEMENT title (#PCDATA)>
  <!ELEMENT artist (#PCDATA)>
  <!ELEMENT price (#PCDATA)>]>
  <cd genre="alternative">

See Also

Validation of XML with Schemas | XDR Validation with XmlSchemaCollection | XML Schema (XSD) Validation with XmlSchemaCollection