How to use a custom xsd when edit a XML file in Visual Studio?



By ganton ~ October 27th, 2008. Filed under: Other.

In one of my projects people use NHibernate for accessing database. Today, I saw that when some xml file (mapping or configuration) is edited Visual Studio doesn’t provide intellisense and validation of the schema. Moreover, i found no one in the team to use xsd schemas provided by Hibernate.

The question is how to use custom xsd schemas for editing XML files in VS? Well, It is very easy to add a xsd schema and VS will provide an intellisense and a validation support for us. Let’s assume that we have a new XML file created and we’d like to apply a custom xsd schema to it. We need to go to its properties and to select our xsd file in its Schemas property (see below).

In addition Schemas property allows to add more than one xsd scheme to be applied. That means that you can easy extend web.config file (or any other file) to support several configuration schema and to enjoy VS intellisense and validation support.

I hope everybody agrees that it is easy to edit an XML file with intellisense and validation (see below).

As you can see we have intellisense, validation and even auto complete which makes our live much easier.

Leave a Reply