Introduction

This article shows how to use a Schema Object Model(SOM) navigator as an arbitrary schema. This is useful when you have a schema and want to generate your own mapping or want to build a custom XML generator or XSD based code generator.

Points of Interest

There's a lot of type checking and casting. That's inherent in the data model used in the SOM. It's not a strongly typed data structure. So you have to check, cast, then use. It would be an interesting exercise to generate a strongly typed XSD model, but I'll leave that for another article.

After you cast the XmlSchemaObject, you can access the Annotation property, which contains an Items property. Check for each item that is of the type XmlSchemaDocumentation. The Markup (string array) property will contain the documentation nodes.