Post-Schema-Validation Infoset (PSVI)

The World Wide Web Consortium (W3C) XML Schema Recommendation discusses the information set (infoset) that must be exposed for pre- and post-schema validation. The Schema Object Model (SOM) views this exposure before and after the Compile method is called.

The pre-schema-validation infoset is built during the editing of the schema. The post-schema-validation infoset is generated after the Compile method is called, during compilation of the schema, and is exposed as properties.

The SOM is the object model that represents the pre- and post-schema-validation infosets. All properties that have both read and write methods belong to the pre-schema-validation infoset, while all read-only properties belong to the post-schema-validation infoset.

For example, the XmlSchemaElement and XmlSchemaComplexType classes both have BlockResolved and FinalResolved properties. These properties are used to hold the values for the Block and Final properties after the schema has been compiled and validated. BlockResolved and FinalResolved are read-only properties that are part of the post-schema-validation infoset.

The following example shows the ElementType property of the XmlSchemaElement class set after validating the schema. Before validation, the property contains a null reference and the SchemaTypeName is set to the name of the type in question. After validation, the SchemaTypeName is resolved to a valid type, and the type object is available through the ElementType property.

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

Public Class PsviSample
    
   Public Shared Sub ValidationCallbackOne(sender As Object, args As ValidationEventArgs)
      Console.WriteLine(args.Message)
   End Sub 'ValidationCallbackOne

Public Shared Sub Main()
      
      Dim schema As New XmlSchema()
      
      ' Create an element of type integer and add it to the schema.
      
      Dim priceElem As New XmlSchemaElement()
      priceElem.Name = "Price"
      priceElem.SchemaTypeName = New XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema")
      schema.Items.Add(priceElem)
      

'   Print the pre-compilation value of the ElementType property 
'   of the XmlSchemaElement which is a PSVI variable.
'     
      'Console.WriteLine("Before compilation the ElementType of Price is " + priceElem.ElementType)
      Console.Write("Before compilation the ElementType of Price is ")
      Console.WriteLine(priceElem.ElementType)
      

' Compile, which validates the schema and, if valid, will place the PSVI 
' values in certain properties.
'      
      schema.Compile(AddressOf ValidationCallbackOne)
      

' After compilation of the schema, the ElementType property of the 
' XmlSchemaElement will contain a reference to a valid object 
' because the ' SchemaTypeName refered to a valid type.
'      
   'Console.WriteLine("After compilation the ElementType of Price is " + priceElem.ElementType)
      Console.Write("After compilation the ElementType of Price is ")
      Console.WriteLine(priceElem.ElementType)
   End Sub ' Main
   
End Class   
' PsviSample
[C#]
using System.Xml; 
using System.Xml.Schema; 
using System.IO;
using System;

public class PsviSample {

    public static void ValidationCallbackOne(object sender, ValidationEventArgs args) {
   Console.WriteLine(args.Message);
    }

    public static void Main(string[] args){
     
      XmlSchema schema = new XmlSchema();            
      
      /* Create an element of type integer and add it to the schema. */
    
      XmlSchemaElement priceElem = new XmlSchemaElement();
      priceElem.Name = "Price"; 
      priceElem.SchemaTypeName =  new XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema");
      schema.Items.Add(priceElem);
      
      /* 
    Print the pre-compilation value of the ElementType property 
    of the XmlSchemaElement which is a PSVI variable.
      */
      Console.WriteLine("Before compilation the ElementType of Price is " + priceElem.ElementType );
      
      /* 
    Compile, which validates the schema and, if valid, will place the PSVI 
    values in certain properties. 
      */
      schema.Compile(new ValidationEventHandler(ValidationCallbackOne)); 
      
      /* 
After compilation of the schema, the ElementType property of the 
XmlSchemaElement will contain a reference to a valid object because the 
SchemaTypeName refered to a valid type.
      */ 
      Console.WriteLine("After compilation the ElementType of Price is " 
      + priceElem.ElementType );

    }/* Main(string[]) */

}// PsviSample

See Also

XML Schema Object Model (SOM)