Disable XML validation in Eclipse

XmlEclipse

Xml Problem Overview


My Eclipse validates XML files every time I save a file and it takes a while to validate them. The project is created using gwt-maven-plugin.

The XML files are not under any Source folder build path in Eclipse, they are auto generated by SmartGWT under src/main/webapp/[GwtModule]>/sc

Also all these XML files are marked with the error "Content is not allowed in prolog" and every time I run the project I have to confirm that I want to run the project with errors though there are none (and everything works fine).

I tried Suspending all Validators under Eclipse -> Window -> Preferences -> Validation but to no avail.

Any idea how I can stop Eclipse from annoying me every time?

Xml Solutions


Solution 1 - Xml

You have two options:

  1. Configure Workspace Settings (disable the validation for the current workspace): Go to Window > Preferences > Validation and uncheck the manual and build for: XML Schema Validator, XML Validator

  2. Check enable project specific settings (disable the validation for this project): Right-click on the project, select Properties > Validation and uncheck the manual and build for: XML Schema Validator, XML Validator

Right-click on the project and select Validate to make the errors disappear.

Solution 2 - Xml

The other answers may work for you, but they did not cover my case. I wanted some XML to be validated, and others not. This image shows how to exclude certain folders (or files) for XML validation.

Begin by right clicking the root of your Eclipse project. Select the last item: Properties...

enter image description here

(If your browser scales this image very small, right click and open in a new window or tab.)

  • Eclipse appears to be very sensitive if you click the *Browse File... or *Browser Folder... button. This dialog needs some work!

  • This was done using Eclipse 4.3 (Kepler).

Solution 3 - Xml

Window > Preferences > Validation > uncheck XML Validator Manual and Build enter image description here

Solution 4 - Xml

Ensure your encoding is correct for all of your files, this can sometimes happen if you have the encoding wrong for your file or the wrong encoding in your XML header.

So, if I have the following NewFile.xml:

<?xml version="1.0" encoding="UTF-16"?>
<bar foo="foiré" />

And the eclipse encoding is UTF-8:

Eclipse Encoding Resource

The encoding of your file, the defined encoding in Eclipse (through Properties->Resource) and the declared encoding in the XML document all need to agree.

The validator is attempting to read the file, expecting <?xml ... but because the encoding is different from that expected, it's not finding it. Hence the error: Content is not allowed in prolog. The prolog is the bit before the <?xml declaration.

EDIT: Sorry, didn't realise that the .xml files were generated and actually contain javascript.

When you suspend the validators, the error messages that you've generated don't go away. To get them to go away, you have to manually delete them.

  1. Suspend the validators
  2. Click on the 'Content is not allowed in prolog' message, right click and delete. You can select multiple ones, or all of them.
  3. Do a Project->Clean. The messages should not come back.

I think that because you've suspended the validators, Eclipse doesn't realise it has to delete the old error messages which came from the validators.

Solution 5 - Xml

In JBoss Developer 4.0 and above (Eclipse-based), this is a tad easier. Just right-click on your file or folder that contains xml-based files, choose "Exclude Validation", then click "Yes" to confirm. Then right-click the same files/folder again and click on "Validate", which will remove the errors with a confirmation.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSatishView Question on Stackoverflow
Solution 1 - XmlMahmoud SalehView Answer on Stackoverflow
Solution 2 - XmlkevinarpeView Answer on Stackoverflow
Solution 3 - XmlMarkView Answer on Stackoverflow
Solution 4 - XmlMatthew FarwellView Answer on Stackoverflow
Solution 5 - XmlFuzzy AnalysisView Answer on Stackoverflow