Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Visual Studio's validation of non-xml files that look like xml?

I have a bunch of Velocity template files in a Visual Studio 2008 project, the problem is that despite the fact that the extension is .vm instead of .xml or similar Visual Studio thinks that the HTML they contains must conform to XML naming standards and generates errors (not just warnings even) on each compilation.

How do I tell Visual Studio to ignore these "faulty" XML files? I am willing to turn of all validation on XML but I have found no such option either.

Update, the errors don't stop the build they just drown the real errors behind about 20 validation errors. I seem to remember an option to turn off validation in VS 2005 but I can't find any such option in VS 2008.

I'm accepting adding ## to the beginning of the file as answer, it does the trick even if it's ugly. Thanks Nir!

Update 2 I thought I had tried your answer before Marc and found that it wasn't properly remembered. But now that I tried it again it does work very well, and it's cleaner than adding a comment to every file. Re-rewarding the accepted answer.

like image 749
kaa Avatar asked Oct 12 '08 09:10

kaa


People also ask

How do I beautify XML in Visual Studio?

To access XML formatting options, choose Tools > Options > Text Editor > XML, and then choose Formatting.

What is XML document validation?

XML validation is the process of determining whether the structure, content, and data types of an XML document are valid. XML validation also strips off ignorable whitespace in the XML document.

Can we validate XML documents against a schema?

You can validate your XML documents against XML schemas only; validation against DTDs is not supported. However, although you cannot validate against DTDs, you can insert documents that contain a DOCTYPE or that refer to DTDs.

What is XML DTD validation?

DTD is the acronym for Document Type Definition. This is a description of the content for a family of XML files. This is part of the XML 1.0 specification, and allows one to describe and verify that a given document instance conforms to the set of rules detailing its structure and content.


3 Answers

Xml errors usually only show if the file is open.

You can normally disable it by not opening it into the xml editor; the errors don't normally stop a build - they just look like they do. Right click -> Open With... Source (Text) Editor (or HTML if you prefer) (and set as default).

like image 134
Marc Gravell Avatar answered Oct 21 '22 02:10

Marc Gravell


I add a comment as the first line of the vm file, that way the file doesn't begin with a < and VS doesn't think it's an xml file.

Just add ## as the first line of every file then close and reopen it.

like image 28
Nir Avatar answered Oct 21 '22 01:10

Nir


Have you tried: right-click on a .VM file, select Properties. There you can change the Build Action, you might want to set it to either Content or None.

like image 1
steffenj Avatar answered Oct 21 '22 00:10

steffenj