Share via


XML Editor in VS2005: Schema Cache and Schema Catalogs

Below are a few tips and tricks on using schema cache and schema catalogs with the new XML Editor in VS 2005.

Schema Cache

The XML Editor comes with a set of schemas that describe some of the W3C standard and some of the VS specific XML namespaces.  These schemas are installed into your VS installation directory under %vsinstalldir%\xml\schemas.  When you declare one of the namespacess defined by these schemas in your XML files, the XML Editor will automatically associate appropriate schema(s) from the cache location and instantly provide you with intellisense data and validation.  The purpose of the schema cache directory is to hold standard schemas as well as schemas that are unlikely to change.

The following operations are supported by the XML Editor without requiring a VS restart.
- Adding schemas
- Deleting schemas
- Renaming schemas

You can also change the schema cache location.  This is done by modifying Cache Directory Location on Tools | Options | Text Editor | XML | Miscellaneous dialog.  When you do this, the XML Editor will stop using schemas from the old location and instead switch to the new folder.

Schema Catalogs

You can extend existing schema cache using catalog.xml file.  VS installs a sample catalog.xml file (along with catalog.xsd) in the schema cache folder.  This file can be used to do several things.  First of all, you can associate namespaces with external locations as in the following example:

<

Schema href="%VsInstallDir%/Common7/IDE/Policy/Schemas/TDLSchema.xsd"

   targetNamespace="https://www.microsoft.com/schema/EnterpriseTemplates/TDLSchema"/>

You can also associate file extensions with specific namespaces.  The following line taken from the sample catalog.xml associates .config files with dotNetConfig.xsd schema

<

Association extension="config" schema="%VsInstallDir%/xml/schemas/dotNetConfig.xsd"/>

Finally, you can point your catalog to another catalog file creating a chain:

<

Catalog href="https://mycompany/catalog.xml"/>

Comments

  • Anonymous
    September 19, 2005

    If this is extended to a web based store (e.g. the set of schemas used for A2A comms in your enterprise) and that store is not terribly responsive (e.g. takes >100ms to respond) would there be any impact on the responsiveness of VS2005's XML editor?

  • Anonymous
    September 20, 2005
    All the validation is done on a background thread, so there won't be any UI blocking. However, you might not be able to get full validation and intellisense until the XML Editor reads all the schemas.

    Stan

  • Anonymous
    February 14, 2007
    Oops. With all of the excitement of doing 2 webcasts in one day yesterday, I forgot to blog the wrap-up

  • Anonymous
    July 17, 2007
    Stan, How is the catalog being used by Intellisense ? I'm trying to use URI like "urn:oasis:names:tc:dita:concept.xsd:1.1" as targetNamespace (in the catalog and in the XML document).  However, it seems like intellisense doesn't like prefixes other than file: or http:.

  • Anonymous
    March 15, 2008
    PingBack from http://blogrssblog.info/stan-kitsis-xml-editor-in-vs2005-schema-cache-and-schema-catalogs/

  • Anonymous
    January 20, 2009
    PingBack from http://www.hilpers.com/1030931-xml-schema-bei-vs2005-bekanntmachen