Partager via


Validation schemas for various browsers

In VS Whidbey HTML Editor Target browser schemas are static. Same, btw, about page directive schemas and schemas that describe limited markup in such files as Global.asax. Yes, you can create your own schemas if you wish. However, a few things are important to remember. First, we do not support all richness of the XML Schema syntax. For instance, xsd:extension is not supported. There is limited support for xsd:include, but it is far from what is described in W3C documents. The best approach would be to take of the schemas we ship, create a copy and tweak it. You can place it then in Program Files\Microsoft Visual Studio\Common7\Packages\Schemas\HTML and add it to the registry. See HKLM\Software\Microsoft\Visual Studio\8.0\HTML Editor\Schemas for example. As opposed to VS 2003, Whidbey does not sniff schema files in the Schemas folder on IDE startup. Why? Opening and closing twenty or so files is expensive.

 

Why don't we support full XSD standard? Mostly for performance reasons. Although we do use MSXML to load and parse the schema, we then construct custom cache of elements, their attributes and parent/child relations. This allows us to avoid subsequent XPath queries which may become slow as your HTML document grows. We (and you, I believe) want intellisense dropdown to appear fast since I doubt you’ll want to wait a few seconds before intellisense window appears showing list of attributes for a particular element.

 

Why did we use XML Schemas at all? It is a good question. In VS 2002/2003 HTML editor was also XML editor hence the shared validation engine. However, given limited resources we only went so far in supporting XML schema syntax. Main target customer was not professional XML developer, but an ordinary user that needed to create and edit [mostly simple] data-related XML files and small schemas. Why didn't we use MSXML for validation? Unfotunately, standard XML validators bark on a fisrt error. This is what what most people want. Would you like C++ compiler to stop at the fist missing semicolon? I guess not.

 

In Whidbey there is completely new, separate XML editor that supports, I believe, the whole validation enchilada including DTDs. That very editor, btw, is used to edit web.config files so you finally get intellisense in web.confg and machine.config. It is fully managed, written in C# (except the VS Core text editor which is shared across VS products and is written in C++). It is based on System.XML and was written by the same people who implemented System.XML.

 

The only XML format that my team still owns is Windows Scripting Host. This is because those files contain jscript/vbscript and we provide client script intellisense.

 

Life is not simple and neither is software design :-)