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="http://staff.develop.com/candera/schemas/IntelliSchema.xsd"
elementFormDefault="qualified"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/2001/XMLSchema">
<xs:element name="foo">
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
Cool. Now someone has to come up with a hand-crafted XSD for machine.config and web.config ...
ReplyDeleteWhich might be tough: can you write a schema for a pile of non-namespace-qualified XML? I don't actually know - anyone?
ReplyDeleteThat was one thing that MSFT totally screwed up with the config files - they're in no namespace.
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: http://www.radsoftware.com.au/web/CodeZone/Articles/XSLIntellisenseInVisualStudio.aspx
ReplyDeleteOne way to do web.config and machine.config is to hack in a "temporary" namespace and then remove it when finished editing.
ReplyDeletehttp://www.radsoftware.com.au/web/CodeZone/Articles/IntellisenseWebConfig.aspx