XSD Schema Sample

Sample Overview

This sample illustrates how to read an XML Schema definition language (XSD) file into the Schema Object Model (SOM). Then, the sample writes the XSD schema that has been loaded into memory to a XmdTextWriter attached to the console for display to the user.

This sample loads several example .XSD schema files into XmlSchema objects.  It then iterates over the object model to output a labeled form of the schema to the console. The sample then uses the XSD Schema Object Model to create an example XML file filled with generic content that matches the XSD schema. This demonstrates the power of the object model to generate and manipulate XML that conforms to a schema.

Sample Source and Build Output Locations

The sample source is found in sscli\samples\howto\xml\xmlschema. 

The source file is:

The build output location is %TARGETCOMPLUS%\samples\xml\xmlschema. The output file is an executable assembly named xmlschema.exe.

The sample uses two XSD files:

Building the Sample

All samples are built from the buildall script. 

You can also build all the samples by switching to the root of the sample directory, sscli\samples, and typing build -c.

You can build this specific sample by switching to the sample directory and typing build -c.

Running the Sample

These steps require that the Shared Source CLI (SSCLI) be already built and functional.

  1. Run env.bat or source the env.csh or env.sh script files, depending on your platform.
  2. Switch to the %TARGETCOMPLUS%\samples\xml\xmlschema directory.
  3. Type the following command:

    clix xmlschema.exe


Copyright (c) 2002 Microsoft Corporation. All rights reserved.