Manipulating an Existing Schema

You already know how to load any XML document into memory. Once you have a document in memory, you can navigate through its elements using XmlDocument’s standard methods, and read it into an XmlSchema for other purposes:

XmlDocument document = new XmlDocument( );
document.Load(args[0]);

XmlNodeReader reader = new XmlNodeReader(document);

ValidationEventHandler handler = new ValidationEventHandler(Handler);
XmlSchema schema = XmlSchema.Read(reader, handler);

schema.Compile(handler);

I n much the same way, you can use XmlDocument’s GetNavigator( ), SelectNodes( ), and SelectSingleNode( ) methods to navigate an XSD. You can also transform it into any other format, given an appropriate XSLT stylesheet. For example, you might wish to transform an XSD into a DTD; you could write an XSLT transform to do so.

Get .NET & XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.