How to fix the Eclipse validation error "No grammar restrictions found for document"?

Eclipse 3.5.2 issues an XML schema warning:

No grammar constraints (DTD or XML schema) detected for the document. 

File application.xml:

 <?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5"> </application> 

I do not want to turn off the warning. How can I get Eclipse to validate an XML document correctly?

+51
java eclipse java-ee xsd
Jan 28 2018-11-21T00:
source share
16 answers

Not sure if you ever resolved this satisfactorily, but today I came across this publication while working with some Spring configuration files in Eclipse 3.6. I could not make the error go away in the "Problems" view in Eclipse no matter what, until I right-clicked on the problem and deleted it.

I decided that he would return if I return to action, and in fact there was a problem, and so far this is not the case. The fact is that I had an almost identical Spring configuration file that did not show an error.

It would seem that sometimes things just get stuck in Eclipse. Not sure why, but between this and files that don't sync with editors and force me to update, I guess I should accept it.

+38
Mar 27 '11 at 20:51
source share

Including this at the top of any abusive file works for me:

 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE project> 
+51
Jul 30 '13 at 18:34
source share

This is another way to turn off warnings for XML documents that are intentionally missing from DTP or XSD:

  • Go to Menu Settings,
  • in the navigation menu, that is, in the left frame of the dialog box, select: XML> XML files> Validation
  • in the configuration area, that is, in the right frame of the dialog box, select: Check files> No specified grammar> Ignore (this is a selection field), by default a warning)
+30
Nov 16 '12 at 12:29
source share

I am not an expert, but a student. I accidentally found an easy and stupid way to solve the problem. You just need to do the following:

Press ctrl + shift + F (this is a shortcut for formatting a file in Eclipse)

If this does not solve the problem, press the TAB key at the beginning of this particular line
?xml version="1.0" encoding="UTF-8"? and nowhere else (I don’t know why, but it works. If anyone knows why I will be very happy to know)

Then press ctrl + shift + F and save.

The warning will disappear, at least for me, you can try yourself ...

+6
Sep 17 '13 at 14:05
source share

If this warning appears, it means that the XML Validate function (other than the XML instance editor!) Did not know what to use DTD or XSD. This, of course, also means that it did not actually check if the XML instance is compatible with any schema.

Therefore, this is a useful warning, it cannot be turned off (if you use the "Check" menu function and expect it to do something).

You can use the settings so that your circuit is known:

  • Open Settings / XML Catalog / User Entries
  • Click Add ...
  • Enter the XSD file to use in the "Location"
  • Select the key type "Schema Location" (if you have xsi: schemaLocation)
  • Enter the URL (second part of the location) corresponding to the contents of the files as “Key”
  • Click OK
  • Go to the Problem view and remove the validation warning.
  • Right-click the XML file and select Check Again

Some public schema identifiers and locations are already contained in the "Records with the plugin" section (especially if you have WSTP installed). You will not receive a warning for these namespaces (since it uses the copy provided by the system for verification).

+5
Jul 28 '15 at 16:39
source share

in eclipse to avoid the “ grammar restrictions (dtd or xml) found for the document. ” I use to add the xsd schema file to the xml directory in

"Window \ preferences \ xml \ xml directory \ User Entries."

Click the Add button on the right.




Example:

 <?xml version="1.0" encoding="UTF-8"?> <HolidayRequest xmlns="http://mycompany.com/hr/schemas"> <Holiday> <StartDate>2006-07-03</StartDate> <EndDate>2006-07-07</EndDate> </Holiday> <Employee> <Number>42</Number> <FirstName>Arjen</FirstName> <LastName>Poutsma</LastName> </Employee> </HolidayRequest> 

From this xml, I generated and saved xsd under: /home/my_user/xsd/my_xsd.xsd

Like the location: /home/my_user/xsd/my_xsd.xsd

As key type: namespace name

As a key: http://mycompany.com/hr/schemas




Close and reopen the xml file and make some changes to break the scheme, you should be notified.

+3
May 31 '12 at 14:04
source share

I had some success back to the V1.4 .xsd application . If someone can explain why the JavaEE version is not working, I would appreciate it.

 <?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" version="1.4"> 
+2
Jan 28 2018-11-11T00:
source share

Here's a working solution for this task:

Step 1: Right-click on the project and go to Properties

Step 2. Go to the "libraries" and delete the project "System Library JRE"

Step 3: Click “Add Library” → “JRE Library” → select “Default JRE Workspace”

Step 3. Go to the "Order and Export" section and check the recently added "JRE System Library"

Step 4: Update and Clean Up the Project

Eureka! He works:)

+1
May 11 '13 at 11:28
source share

Add this to your XML file from the start:

 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE RelativeLayout> 

Change the RelativeLayout to your own root layout, then find the xml file on the left side, in the layout folder, right-click and select “Confirm”.

+1
Apr 16 '16 at 9:56 on
source share

What I found for me was to completely remove the schemaLocation attribute, and then right-click in the diagram view and go to the namespace, and then add the diagram location hint to the resulting dialog.

0
05 Feb '11 at 11:52
source share

This may be due to proxy settings. See this and this . You can try adding javadoc at the url to the library without it. If this is normal in your browser but not in your editor, then this is a connection problem. I solved the same problem by setting the proxy settings for the administrator. Although all other applications did work, eclipse did not, so I had to enter the configuration manually. It would be great if the developers added a "check connection" button ...

0
Nov 11 '11 at 16:05
source share

Solution for Eclipse:

add <!DOCTYPE something> to the beginning of each problematic XML,

after the xml <?xml version="1.0" encoding="utf-8"?> tag <?xml version="1.0" encoding="utf-8"?>

you can write something for doctype, but basically it should be explicit, active, etc. from what I understand

0
Oct 10 '13 at
source share

I had this problem last night (using eclipse V.kepler). I am brand new to java and eclipse and I am trying to teach myself how to make an Android app. While I was working on the lessons offered on developers.android.com, I put this into my main_activity_actions.xml file:

 <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <!-- Search should appear as an action button --> <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" android:showAsAction="ifRoom"/> </menu> 

This gave me the same error as the OP. I tried to make an offer

 <!DOCTYPE project> 

just below the first line, and she solved the problem.

0
Mar 11 '14 at 1:14
source share

What worked for me is to right-click the XML file in the tree (usually on the left side in eclipse) and click on confirmation. Since then, the warning has never returned.

0
Jul 08 '15 at 6:13
source share

Here is what worked for me. I used schemes without version numbers (e.g. spring-beans.xsd , not spring-beans-4.1.xsd ), and they probably were updated upstream. I suppose the problem was that Eclipse was keeping a dirty cache of older versions.

Correction:
1. Go to Window -> Preference -> Network Connection -> Cache
2. Remove all cached schemas.
3. Remove any no grammar constraints in the problem representation.
4. Recheck the design.

0
Sep 09 '15 at 18:02
source share

for me it worked like a charm when I cut it (ctrl a + ctrl - X) and saved it again (ctrl-s)! the warning "No grammar restrictions (DTD or XML schema) found for the document" went well!

0
Jun 30 '16 at 9:43
source share



All Articles