MSXML and the Schema Object Model (SOM)
This chapter describes how to build applications that work with XML schemas by using MSXML, the Microsoft XML Core Services. The components that make up MSXML support the established APIs as well as such languages like XSLT and XPath. In the latest version of MSXML, Microsoft has also provided full support for XML schemas through the addition of the Schema Object Model (SOM). By using both the standard XML components of MSXML and the XML schema-specific SOM, developers can create and examine XML schemas in addition to performing validation of XML documents.
18.1 Introducing MSXML
For those who have not worked with MSXML in the past, it might help to understand what MSXML is and what it can be used for. The Microsoft XML Core Services, or MSXML, is a COM-based library of components that consume and (or) generate XML. This library is free and downloadable from the Microsoft Web site. The most recent release of MSXML is version 4.0. The components are contained in the application extension file msxml4.dll.
The most recent version of the Microsoft XML Core Services can be found at the Microsoft Developer Network Site, specifically at: http://msdn.microsoft.com/library/default.asp?url=/downloads/list/xmlgeneral.asp
In addition to MSXML, Microsoft has a variety of other XML-related downloads that are free. Be aware that a preview version of MSXML 4.0 was released, and that version must be uninstalled prior to installing this final release.
MSXML 4.0 contains a variety of components and interfaces that can be used to work with XML. For parsing documents, MSXML contains implementations of both the Document Object Model (DOM) Level 2 and SAX2 feature sets. For performing transformations, there is an XSLT processor. XPath queries are supported throughout the tools as well, and there are even components to simplify access to XML documents over HTTP. Figure 18.1 lists the APIs and standards supported in MSXML.
With such a large number of components and a depth of features, covering MSXML in any detail would take more than this chapter. This chapter focuses just on the features of MSXML 4.0 that relate specifically to XML schemas. These include the capability to examine and create XML schemas and to validate XML documents by using XML schemas. To do this, we examine some of the basic features of MSXML, and then we examine the Schema Object Model in detail.
FIGURE 18.1 MSXML overview.
Version 4.0 of MSXML is contained in the file msxml4.dll. As in previous versions of MSXML, version 4.0 can exist on the same machine as previous versions of MSXML in a side-by-side compatibility mode. This is possible because the components made available in 4.0 are registered with identifiers (CLSIDs) different from those of their older counterparts. To make sure you are working with version 4.0, be sure to use components such as DOMDocument40 whose CLSIDs end with '40'.