Thursday, August 7, 2003

Schema Intellisense in VS.NET

The other day, I was playing around with Microsoft’s Enterprise Instrumentation Framework (EIF), and I got to wondering how it was that VS.NET “knew” about the schema for the configuration files. You see, it was giving me Intellisense in the XML editor, letting me know what elements and attributes were legal to appear as children of whatever element I was inside. Very cool.

I thought maybe it was going to the namespace URI and downloading the schema, but opening a browser and pointing it to the URL in question yielded nothing, so that couldn’t be it. After a bit of poking, I discovered that what it was doing was looking in a particular directory for schemas. On my machine, that directory is C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml. This morning I whipped up this new schema:

<?xml version="1.0" encoding="utf-8" ?>

<xs:schema targetNamespace=""





  <xs:element name="foo">


      <xs:choice minOccurs="1" maxOccurs="unbounded">


  1. Cool. Now someone has to come up with a hand-crafted XSD for machine.config and web.config ...

  2. Which might be tough: can you write a schema for a pile of non-namespace-qualified XML? I don't actually know - anyone?

    That was one thing that MSFT totally screwed up with the config files - they're in no namespace.

  3. Great! I have always wanted Intellisense for editing XSL in Visual Studio. I put a few hours into making a schema. It can be downloaded here:

  4. One way to do web.config and machine.config is to hack in a "temporary" namespace and then remove it when finished editing.