I just discovered the beauty of Visual Studio's automatic XSD schema generation.*
Is there an easy way to have VS automatically attach files with particular names to existing XSD schema? So if I have myconfig.xml
files scattered throughout a project (or several projects) I would want them to always validate against myconfig.xsd
, rather than have to open each XML file and associate it manually. Is this possible?
* For those who aren't familiar: Open XML file, XML/Create Schema, and it creates a nice schema file based on what it sees in your XML file. You can then attach the same XSD to another XML file by opening that file and choose XML/Schemas and choosing the appropriate schema from your project. You then get intellisense and validation on all your element and attribute names, required elements and attributes, etc.
Update: I think I wasn't really clear.
When I create a new web.config
file anywhere in a project, I don't manually assign a schema to it. There's no namespace specified within the XML. Nevertheless Visual Studio automatically knows to use DotNetConfig.xsd
:
Presumably Visual Studio has a mapping somewhere that assigns files named web.config
to DotNetConfig.xsd
.
Now, suppose I want all files named DbSchema.xml
to automatically use a schema I created called DbSchema.xsd
. Is there a way to do that?