4.4 The Schema Library

The Schema Library is a collection of XML schemas and associated files located on the user's machine. Each machine has its own schema library (with each schema library entry having the option of applying to all users or only to the current user). Schema library entries are stored in the Windows Registry. Each schema library entry is identified by a unique target namespace URI, refers to a schema document, and optionally refers to additional supporting files, such as XSLT stylesheets.

The purpose of the schema library is to allow Word (and other applications, such as Excel) to locate schemas and XSLT stylesheets for use in custom XML editing solutions. For example, when Word opens an arbitrary XML document, it checks the schema library to see if there is an appropriate onload XSLT stylesheet to apply, based on the namespace of the document's root element. Likewise, once the stylesheet has been applied, it associates the result document with zero or more schemas in the schema library, depending on the namespace declarations present in the result of the onload transformation. This association, called "schema attachment," enables on-the-fly schema validation.

Schema library entries can be manually created and modified through the Word UI. Figure 4-8 shows an example of a schema library entry, as shown in the Schema Library dialog, which you can access by selecting Tools Templates and Add-Ins . . . XML Schema Schema Library . . . .

Figure 4-8. A schema library entry as shown in the Word UI

The schema library entry shown in Figure 4-8 is what a user's machine must have in order for our press release example to work correctly. There are several things to note about this entry:

  • The friendly name, or alias, for this entry is "Press Release," as shown in the "Select a schema" list.

  • The namespace URI is http://xmlportfolio.com/pressRelease, which corresponds to the namespace of press release instance documents.

  • The schema document is stored as a file named pressRelease.xsd.

  • There is one "solution" (alias "Elegant") associated with this entry. This refers to an onload XSLT stylesheet, which is stored as a file named pr2word.xsl. Elsewhere in the Word UI, this is called an "XML data view." Here it is called a "solution."

Although schema library entries can be created manually on each user's machine using the dialog in Figure 4-8, there are also automatic deployment mechanisms that approach the simplicity of the scenario described above (where the IT department simply delivers a .xml template file to the PR department). These are discussed briefly later in Section 4.14.

Figure 4-9 shows the same schema library entry as represented in the Windows Registry Editor.

Figure 4-9. A schema library entry as shown in the Windows Registry Editor

Don't worry, you won't be needing to edit your registry directly. We included this just to help demystify how and where the schema library information is stored. Should you want to investigate such entries yourself, the schema library for a specific user is stored under HKEY_USERS\SID\SOFTWARE\Microsoft\Schema Library, and the schema library for all users on a machine is stored under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Schema Library. As always, be careful you don't make any accidental changes. The Registry Editor is not for the faint of heart.

Office 2003 XML
Office 2003 XML
ISBN: 0596005385
EAN: 2147483647
Year: 2003
Pages: 135

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net