1

I get allways this error when I create a .xml file with Eclipse. I did a research and other say that one should do clean and rebuild the project but I am not able to use this because it is grayed out. I hope you can help me.

Thank you in advance for every help!

This is my xml file:

    <?xml version='1.0' encoding='UTF-8'?>
<project name="My XML Build-File with ANT Peoject and JAVA">

<target name="main target">
<echo>executing main target...</echo>
</target>

<target name="target two">
    <echo>executing target two...</echo>
    </target>

</project>
CMS
  • 704
  • 3
  • 9
  • 32
  • please show us the error message... – Lukas Warsitz Nov 11 '13 at 14:39
  • Hi, the error is on german so I will try to translate it as good as I can. It says: "the document is invalid. No grammar found". – CMS Nov 11 '13 at 14:42
  • 1
    Can you show us the beginning of the XML document? Does it have a DOCTYPE declaration that specifies a DTD? When/where exactly does the error occur: when you try to save the XML document? Immediately when you create a new, empty one? when you tell Eclipse to validate the document? – LarsH Nov 11 '13 at 14:45
  • Ok the error is: "Dokument ist ungültig.Keine Grammatik gefunden." – CMS Nov 11 '13 at 14:47
  • Yes the error occures immediately after I create an empty XML. – CMS Nov 11 '13 at 14:49

2 Answers2

3

This typically happens when you 'Validate' an XML document (or the project the document is in).

If you select the document, and you have your 'Problems' view open, it will look like:

enter image description here

You have some options.

The simplest is to click on the problem in the Problems view and then hit 'Delete'. Gone!

if you have lots of them, then try sorting the problems by description, then selecting them all, and hitting delete then.

There is also a couple of other answers here on SO, but none of them are satisfactory to me.

How to fix Eclipse validation error "No grammar constraints detected for the document"?

The trick is then to avoid them in future by turning off the warning too...

All the best.

Community
  • 1
  • 1
rolfl
  • 17,539
  • 7
  • 42
  • 76
  • Hi rolfl, thank you for the help! Yes it is like you said but my complier shows "errors" and no "warnigs". I mean the red dot mit the white cross on it. But I did it like you said I selected the error and deleted them. Now it builds the xml fine. It is this the proper way to solve this kind of problems? – CMS Nov 11 '13 at 14:52
  • It's perhaps not as simple, I did not realize you had an error (as opposed to a warning). I would follow the advice on the last link and set the 'No Grammar Specified' to 'Ignore'. – rolfl Nov 11 '13 at 15:02
  • Hi @rolfl, I hope that you can help this time, too. I created now a new .xml file and I get a new error. It says "preamature end of file". And I only have this in the xml file **** – CMS Nov 11 '13 at 15:32
  • What is it that you are doing to cause these validation situations to happen? Regardless, this one is sgnificant. An XML document needs a root element. The document you have is not valid (even without a grammar). Add `` to the file and it will validate. Again, though, don't try to validate your documents if they are not valid.... – rolfl Nov 11 '13 at 15:43
  • I added the root tag now I got an other error that says "document root element must match doctype root null". I am new to XML so I have no idea what how to get this work. thank you – CMS Nov 11 '13 at 16:12
  • See this answer here: http://stackoverflow.com/a/11429419/1305253 and follow the instructions. – rolfl Nov 11 '13 at 16:19
  • Hi @rolfl, thank you for the link it helped me! I disabled the validation this means I had to uncheck the manual and build for XML Schema Validator and XML validator. The compiler still shows me the error but the build is successful. Thank you! – CMS Nov 12 '13 at 08:45
0

Simply put a tag like

see warning enter image description here

After add tag the warning is disappear enter image description here

MK Vimalan
  • 1,213
  • 14
  • 28